aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LazyValueInfo.cpp
diff options
context:
space:
mode:
authorArtur Pilipenko <apilipenko@azulsystems.com>2016-08-10 12:54:54 +0000
committerArtur Pilipenko <apilipenko@azulsystems.com>2016-08-10 12:54:54 +0000
commita4b6a70a9c158f8dadff38100096dfbdc8d5374d (patch)
treebeb5218e3ed8c68665533e37c1d1aa6da636cfe6 /llvm/lib/Analysis/LazyValueInfo.cpp
parentcb419a896c0016d909f58b5d6b7739f472db6309 (diff)
downloadllvm-a4b6a70a9c158f8dadff38100096dfbdc8d5374d.zip
llvm-a4b6a70a9c158f8dadff38100096dfbdc8d5374d.tar.gz
llvm-a4b6a70a9c158f8dadff38100096dfbdc8d5374d.tar.bz2
[LVI] Relax the assertion about LVILatticeVal type in getConstantRange
The problem was triggered by my recent change in CVP (D23059). Current code expected that integer constants are represented by constantrange LVILatticeVal and never represented as LVILatticeVal with constant tag. That is true for ConstantInt constants, although ConstantExpr integer type constants are legally represented as constant LVILatticeVal. This code fails with CVP change in: @b = global i32 0, align 4 define void @test6(i32 %a) { bb: %add = add i32 %a, ptrtoint (i32* @b to i32) ret void } Currently getConstantRange code is not executed by any of the upstream passes. I'm going to add a test case to test/Transforms/CorrelatedValuePropagation/add.ll once I resubmit the CVP change. Reviewed By: sanjoy Differential Revision: http://reviews.llvm.org/D23194 llvm-svn: 278217
Diffstat (limited to 'llvm/lib/Analysis/LazyValueInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LazyValueInfo.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index d050192..f58e11e 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -1537,11 +1537,14 @@ ConstantRange LazyValueInfo::getConstantRange(Value *V, BasicBlock *BB,
const DataLayout &DL = BB->getModule()->getDataLayout();
LVILatticeVal Result =
getCache(PImpl, AC, &DL, DT).getValueInBlock(V, BB, CxtI);
- assert(!Result.isConstant());
if (Result.isUndefined())
return ConstantRange(Width, /*isFullSet=*/false);
if (Result.isConstantRange())
return Result.getConstantRange();
+ // We represent ConstantInt constants as constant ranges but other kinds
+ // of integer constants, i.e. ConstantExpr will be tagged as constants
+ assert(!(Result.isConstant() && isa<ConstantInt>(Result.getConstant())) &&
+ "ConstantInt value must be represented as constantrange");
return ConstantRange(Width, /*isFullSet=*/true);
}