llvm.org GIT mirror llvm / a1b95f5
Fix typos noticed by Benjamin Kramer. Also make the checks stronger and test that we reject ranges that overlap a previous wrapped range. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157749 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 8 years ago
3 changed file(s) with 61 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
30533053
  • The range should not represent the full or empty set. That is,
  • 30543054 a!=b.
    30553055
    3056

    In addiion, the pairs must be in signed order of the lower bound and

    3057 they must be non contigous.

    3056

    In addition, the pairs must be in signed order of the lower bound and

    3057 they must be non-contiguous.

    30583058
    30593059

    Examples:

    30603060
    6767 #include "llvm/ADT/SmallVector.h"
    6868 #include "llvm/ADT/StringExtras.h"
    6969 #include "llvm/ADT/STLExtras.h"
    70 #include "llvm/Support/ConstantRange.h"
    7071 #include "llvm/Support/ErrorHandling.h"
    7172 #include "llvm/Support/raw_ostream.h"
    7273 #include
    13611362 visitInstruction(GEP);
    13621363 }
    13631364
    1365 static bool isContiguous(const ConstantRange &A, const ConstantRange &B) {
    1366 return A.getUpper() == B.getLower() || A.getLower() == B.getUpper();
    1367 }
    1368
    13641369 void Verifier::visitLoadInst(LoadInst &LI) {
    13651370 PointerType *PTy = dyn_cast(LI.getOperand(0)->getType());
    13661371 Assert1(PTy, "Load operand must be a pointer.", &LI);
    13831388 unsigned NumRanges = NumOperands / 2;
    13841389 Assert1(NumRanges >= 1, "It should have at least one range!", Range);
    13851390
    1386 APInt LastHigh;
    1391 ConstantRange LastRange(1); // Dummy initial value
    13871392 for (unsigned i = 0; i < NumRanges; ++i) {
    13881393 ConstantInt *Low = dyn_cast(Range->getOperand(2*i));
    13891394 Assert1(Low, "The lower limit must be an integer!", Low);
    13951400
    13961401 APInt HighV = High->getValue();
    13971402 APInt LowV = Low->getValue();
    1398 Assert1(HighV != LowV, "Range must not be empty!", Range);
    1403 ConstantRange CurRange(LowV, HighV);
    1404 Assert1(!CurRange.isEmptySet() && !CurRange.isFullSet(),
    1405 "Range must not be empty!", Range);
    13991406 if (i != 0) {
    1400 Assert1(Low->getValue().sgt(LastHigh),
    1401 "Intervals are overlapping, contiguous or not in order", Range);
    1402 if (i == NumRanges - 1 && HighV.slt(LowV)) {
    1403 APInt First = dyn_cast(Range->getOperand(0))->getValue();
    1404 Assert1(First.sgt(HighV),
    1405 "First and last intervals are contiguous or overlap", Range);
    1406 }
    1407 Assert1(CurRange.intersectWith(LastRange).isEmptySet(),
    1408 "Intervals are overlapping", Range);
    1409 Assert1(LowV.sgt(LastRange.getLower()), "Intervals are not in order",
    1410 Range);
    1411 Assert1(!isContiguous(CurRange, LastRange), "Intervals are contiguous",
    1412 Range);
    14071413 }
    1408 LastHigh = High->getValue();
    1409 }
    1414 LastRange = ConstantRange(LowV, HighV);
    1415 }
    1416 if (NumRanges > 2) {
    1417 APInt FirstLow =
    1418 dyn_cast(Range->getOperand(0))->getValue();
    1419 APInt FirstHigh =
    1420 dyn_cast(Range->getOperand(1))->getValue();
    1421 ConstantRange FirstRange(FirstLow, FirstHigh);
    1422 Assert1(FirstRange.intersectWith(LastRange).isEmptySet(),
    1423 "Intervals are overlapping", Range);
    1424 Assert1(!isContiguous(FirstRange, LastRange), "Intervals are contiguous",
    1425 Range);
    1426 }
    1427
    1428
    14101429 }
    14111430
    14121431 visitInstruction(LI);
    8282 ret i8 %y
    8383 }
    8484 !9 = metadata !{i8 0, i8 2, i8 1, i8 3}
    85 ; CHECK: Intervals are overlapping, contiguous or not in order
    85 ; CHECK: Intervals are overlapping
    8686
    8787 define i8 @f11(i8* %x) {
    8888 entry:
    9090 ret i8 %y
    9191 }
    9292 !10 = metadata !{i8 0, i8 2, i8 2, i8 3}
    93 ; CHECK: Intervals are overlapping, contiguous or not in order
    93 ; CHECK: Intervals are contiguous
    9494
    9595 define i8 @f12(i8* %x) {
    9696 entry:
    9898 ret i8 %y
    9999 }
    100100 !11 = metadata !{i8 1, i8 2, i8 -1, i8 0}
    101 ; CHECK: Intervals are overlapping, contiguous or not in order
    101 ; CHECK: Intervals are not in order
    102102
    103103 define i8 @f13(i8* %x) {
    104104 entry:
    106106 ret i8 %y
    107107 }
    108108 !12 = metadata !{i8 1, i8 3, i8 5, i8 1}
    109 ; CHECK: First and last intervals are contiguous or overlap
    109 ; CHECK: Intervals are contiguous
    110110
    111111 define i8 @f14(i8* %x) {
    112112 entry:
    114114 ret i8 %y
    115115 }
    116116 !13 = metadata !{i8 1, i8 3, i8 5, i8 2}
    117 ; CHECK: First and last intervals are contiguous or overlap
    117 ; CHECK: Intervals are overlapping
    118
    119 define i8 @f15(i8* %x) {
    120 entry:
    121 %y = load i8* %x, align 1, !range !14
    122 ret i8 %y
    123 }
    124 !14 = metadata !{i8 10, i8 1, i8 12, i8 13}
    125 ; CHECK: Intervals are overlapping
    126
    127 define i8 @f16(i8* %x) {
    128 entry:
    129 %y = load i8* %x, align 1, !range !16
    130 ret i8 %y
    131 }
    132 !16 = metadata !{i8 1, i8 3, i8 4, i8 5, i8 6, i8 2}
    133 ; CHECK: Intervals are overlapping
    134
    135 define i8 @f17(i8* %x) {
    136 entry:
    137 %y = load i8* %x, align 1, !range !17
    138 ret i8 %y
    139 }
    140 !17 = metadata !{i8 1, i8 3, i8 4, i8 5, i8 6, i8 1}
    141 ; CHECK: Intervals are contiguous