[llvm-commits] [llvm] r157749 - in /llvm/trunk: docs/LangRef.html lib/VMCore/Verifier.cpp test/Verifier/range-1.ll
Rafael Espindola
rafael.espindola at gmail.com
Thu May 31 09:04:26 PDT 2012
Author: rafael
Date: Thu May 31 11:04:26 2012
New Revision: 157749
URL: http://llvm.org/viewvc/llvm-project?rev=157749&view=rev
Log:
Fix typos noticed by Benjamin Kramer.
Also make the checks stronger and test that we reject ranges that overlap
a previous wrapped range.
Modified:
llvm/trunk/docs/LangRef.html
llvm/trunk/lib/VMCore/Verifier.cpp
llvm/trunk/test/Verifier/range-1.ll
Modified: llvm/trunk/docs/LangRef.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=157749&r1=157748&r2=157749&view=diff
==============================================================================
--- llvm/trunk/docs/LangRef.html (original)
+++ llvm/trunk/docs/LangRef.html Thu May 31 11:04:26 2012
@@ -3054,8 +3054,8 @@
<li>The range should not represent the full or empty set. That is,
<tt>a!=b</tt>. </li>
</ul>
-<p> In addiion, the pairs must be in signed order of the lower bound and
- they must be non contigous.</p>
+<p> In addition, the pairs must be in signed order of the lower bound and
+ they must be non-contiguous.</p>
<p>Examples:</p>
<div class="doc_code">
Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=157749&r1=157748&r2=157749&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Thu May 31 11:04:26 2012
@@ -68,6 +68,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/ConstantRange.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -1362,6 +1363,10 @@
visitInstruction(GEP);
}
+static bool isContiguous(const ConstantRange &A, const ConstantRange &B) {
+ return A.getUpper() == B.getLower() || A.getLower() == B.getUpper();
+}
+
void Verifier::visitLoadInst(LoadInst &LI) {
PointerType *PTy = dyn_cast<PointerType>(LI.getOperand(0)->getType());
Assert1(PTy, "Load operand must be a pointer.", &LI);
@@ -1384,7 +1389,7 @@
unsigned NumRanges = NumOperands / 2;
Assert1(NumRanges >= 1, "It should have at least one range!", Range);
- APInt LastHigh;
+ ConstantRange LastRange(1); // Dummy initial value
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);
@@ -1396,18 +1401,32 @@
APInt HighV = High->getValue();
APInt LowV = Low->getValue();
- Assert1(HighV != LowV, "Range must not be empty!", Range);
+ ConstantRange CurRange(LowV, HighV);
+ Assert1(!CurRange.isEmptySet() && !CurRange.isFullSet(),
+ "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);
- }
+ Assert1(CurRange.intersectWith(LastRange).isEmptySet(),
+ "Intervals are overlapping", Range);
+ Assert1(LowV.sgt(LastRange.getLower()), "Intervals are not in order",
+ Range);
+ Assert1(!isContiguous(CurRange, LastRange), "Intervals are contiguous",
+ Range);
}
- LastHigh = High->getValue();
+ LastRange = ConstantRange(LowV, HighV);
}
+ if (NumRanges > 2) {
+ APInt FirstLow =
+ dyn_cast<ConstantInt>(Range->getOperand(0))->getValue();
+ APInt FirstHigh =
+ dyn_cast<ConstantInt>(Range->getOperand(1))->getValue();
+ ConstantRange FirstRange(FirstLow, FirstHigh);
+ Assert1(FirstRange.intersectWith(LastRange).isEmptySet(),
+ "Intervals are overlapping", Range);
+ Assert1(!isContiguous(FirstRange, LastRange), "Intervals are contiguous",
+ Range);
+ }
+
+
}
visitInstruction(LI);
Modified: llvm/trunk/test/Verifier/range-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/range-1.ll?rev=157749&r1=157748&r2=157749&view=diff
==============================================================================
--- llvm/trunk/test/Verifier/range-1.ll (original)
+++ llvm/trunk/test/Verifier/range-1.ll Thu May 31 11:04:26 2012
@@ -83,7 +83,7 @@
ret i8 %y
}
!9 = metadata !{i8 0, i8 2, i8 1, i8 3}
-; CHECK: Intervals are overlapping, contiguous or not in order
+; CHECK: Intervals are overlapping
define i8 @f11(i8* %x) {
entry:
@@ -91,7 +91,7 @@
ret i8 %y
}
!10 = metadata !{i8 0, i8 2, i8 2, i8 3}
-; CHECK: Intervals are overlapping, contiguous or not in order
+; CHECK: Intervals are contiguous
define i8 @f12(i8* %x) {
entry:
@@ -99,7 +99,7 @@
ret i8 %y
}
!11 = metadata !{i8 1, i8 2, i8 -1, i8 0}
-; CHECK: Intervals are overlapping, contiguous or not in order
+; CHECK: Intervals are not in order
define i8 @f13(i8* %x) {
entry:
@@ -107,7 +107,7 @@
ret i8 %y
}
!12 = metadata !{i8 1, i8 3, i8 5, i8 1}
-; CHECK: First and last intervals are contiguous or overlap
+; CHECK: Intervals are contiguous
define i8 @f14(i8* %x) {
entry:
@@ -115,4 +115,28 @@
ret i8 %y
}
!13 = metadata !{i8 1, i8 3, i8 5, i8 2}
-; CHECK: First and last intervals are contiguous or overlap
+; CHECK: Intervals are overlapping
+
+define i8 @f15(i8* %x) {
+entry:
+ %y = load i8* %x, align 1, !range !14
+ ret i8 %y
+}
+!14 = metadata !{i8 10, i8 1, i8 12, i8 13}
+; CHECK: Intervals are overlapping
+
+define i8 @f16(i8* %x) {
+entry:
+ %y = load i8* %x, align 1, !range !16
+ ret i8 %y
+}
+!16 = metadata !{i8 1, i8 3, i8 4, i8 5, i8 6, i8 2}
+; CHECK: Intervals are overlapping
+
+define i8 @f17(i8* %x) {
+entry:
+ %y = load i8* %x, align 1, !range !17
+ ret i8 %y
+}
+!17 = metadata !{i8 1, i8 3, i8 4, i8 5, i8 6, i8 1}
+; CHECK: Intervals are contiguous
More information about the llvm-commits
mailing list