diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-31 13:45:46 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-31 13:45:46 +0000 |
| commit | 97d7787788eb4b479a5a077e8d71692fdebee8e9 (patch) | |
| tree | 2f5f27db4e4bb3aac35188c9a091f5b26c9f1fca /llvm/lib | |
| parent | c5bea20e2e3a3dd3b11ce8739b7cdef5e10aa611 (diff) | |
| download | bcm5719-llvm-97d7787788eb4b479a5a077e8d71692fdebee8e9.tar.gz bcm5719-llvm-97d7787788eb4b479a5a077e8d71692fdebee8e9.zip | |
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.
llvm-svn: 157741
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/Verifier.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp index cae3bc8855e..fdffd11f090 100644 --- a/llvm/lib/VMCore/Verifier.cpp +++ b/llvm/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(); } } |

