aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-05-31 13:45:46 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-05-31 13:45:46 +0000
commitc49b29ef5d4071cc4679d5560855f446f95919fc (patch)
tree05467ba198eafc2c05ec42aefee52b4fbeb769db /lib/VMCore
parent177cf1e1a3685209ab805f82897902a8d2b61661 (diff)
Require intervals in the range metadata to be in a canonical form: They must
be non contiguous, non overlapping and sorted by the lower end. While this is technically a backward incompatibility, every frontent currently produces range metadata with a single interval and we don't have any pass that merges intervals yet, so no existing bitcode files should be rejected by this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157741 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Verifier.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index cae3bc8855..fdffd11f09 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -1383,6 +1383,8 @@ void Verifier::visitLoadInst(LoadInst &LI) {
Assert1(NumOperands % 2 == 0, "Unfinished range!", Range);
unsigned NumRanges = NumOperands / 2;
Assert1(NumRanges >= 1, "It should have at least one range!", Range);
+
+ APInt LastHigh;
for (unsigned i = 0; i < NumRanges; ++i) {
ConstantInt *Low = dyn_cast<ConstantInt>(Range->getOperand(2*i));
Assert1(Low, "The lower limit must be an integer!", Low);
@@ -1391,8 +1393,20 @@ void Verifier::visitLoadInst(LoadInst &LI) {
Assert1(High->getType() == Low->getType() &&
High->getType() == ElTy, "Range types must match load type!",
&LI);
- Assert1(High->getValue() != Low->getValue(), "Range must not be empty!",
- Range);
+
+ APInt HighV = High->getValue();
+ APInt LowV = Low->getValue();
+ Assert1(HighV != LowV, "Range must not be empty!", Range);
+ if (i != 0) {
+ Assert1(Low->getValue().sgt(LastHigh),
+ "Intervals are overlapping, contiguous or not in order", Range);
+ if (i == NumRanges - 1 && HighV.slt(LowV)) {
+ APInt First = dyn_cast<ConstantInt>(Range->getOperand(0))->getValue();
+ Assert1(First.sgt(HighV),
+ "First and last intervals are contiguous or overlap", Range);
+ }
+ }
+ LastHigh = High->getValue();
}
}