[llvm] r267618 - [LVI] A better fix for the assertion error introduced by 267609

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 26 15:52:30 PDT 2016


Author: reames
Date: Tue Apr 26 17:52:30 2016
New Revision: 267618

URL: http://llvm.org/viewvc/llvm-project?rev=267618&view=rev
Log:
[LVI] A better fix for the assertion error introduced by 267609

Essentially, I was using the wrong size function.  For types which were sized, but not primitive, I wasn't getting a useful size for the operand and failed an assert.  I fixed this, and also added a guard that the input is a sized type.  Test case is for the original mistake.  I'm not sure how to actually exercise the sized type check.


Modified:
    llvm/trunk/lib/Analysis/LazyValueInfo.cpp
    llvm/trunk/test/Transforms/CorrelatedValuePropagation/basic.ll

Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=267618&r1=267617&r2=267618&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Tue Apr 26 17:52:30 2016
@@ -1002,7 +1002,14 @@ bool LazyValueInfoCache::solveBlockValue
 
 bool LazyValueInfoCache::solveBlockValueCast(LVILatticeVal &BBLV,
                                              Instruction *BBI,
-                                             BasicBlock *BB) {  
+                                             BasicBlock *BB) {
+  if (!BBI->getOperand(0)->getType()->isSized()) {
+    // Without knowing how wide the input is, we can't analyze it in any useful
+    // way.
+    BBLV.markOverdefined();
+    return true;
+  }
+  
   // Figure out the range of the LHS.  If that fails, we still apply the
   // transfer rule on the full set since we may be able to locally infer
   // interesting facts.
@@ -1012,14 +1019,7 @@ bool LazyValueInfoCache::solveBlockValue
       return false;
 
   const unsigned OperandBitWidth =
-    BBI->getOperand(0)->getType()->getPrimitiveSizeInBits();
-  if (OperandBitWidth == 0) {
-    // Without knowing how wide the input is, we can't analyze it in any useful
-    // way.  
-    BBLV.markOverdefined();
-    return true;
-  }
-  
+    DL.getTypeSizeInBits(BBI->getOperand(0)->getType());
   ConstantRange LHSRange = ConstantRange(OperandBitWidth);
   if (hasBlockValue(BBI->getOperand(0), BB)) {
     LVILatticeVal LHSVal = getBlockValue(BBI->getOperand(0), BB);
@@ -1062,7 +1062,8 @@ bool LazyValueInfoCache::solveBlockValue
 
 bool LazyValueInfoCache::solveBlockValueBinaryOp(LVILatticeVal &BBLV,
                                                  Instruction *BBI,
-                                                 BasicBlock *BB) {  
+                                                 BasicBlock *BB) {
+  
   // Figure out the range of the LHS.  If that fails, bail.
   if (!hasBlockValue(BBI->getOperand(0), BB)) {
     if (pushBlockValue(std::make_pair(BB, BBI->getOperand(0))))

Modified: llvm/trunk/test/Transforms/CorrelatedValuePropagation/basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CorrelatedValuePropagation/basic.ll?rev=267618&r1=267617&r2=267618&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/CorrelatedValuePropagation/basic.ll (original)
+++ llvm/trunk/test/Transforms/CorrelatedValuePropagation/basic.ll Tue Apr 26 17:52:30 2016
@@ -429,3 +429,14 @@ entry:
 exit:
   ret i1 %cmp
 }
+
+define i1 @bitcast_unknown2(i8* %p) {
+; CHECK-LABEL: @bitcast_unknown2
+; CHECK: ret i1 %cmp
+entry:
+  %p64 = ptrtoint i8* %p to i64
+  %cmp = icmp sle i64 %p64, 128
+  br label %exit
+exit:
+  ret i1 %cmp
+}




More information about the llvm-commits mailing list