[PATCH] D23194: [LVI] Relax the assertion about LVILatticeVal type in getConstantRange
Artur Pilipenko via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 5 03:15:31 PDT 2016
apilipenko created this revision.
apilipenko added reviewers: regehr, reames.
apilipenko added a subscriber: llvm-commits.
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.
https://reviews.llvm.org/D23194
Files:
lib/Analysis/LazyValueInfo.cpp
Index: lib/Analysis/LazyValueInfo.cpp
===================================================================
--- lib/Analysis/LazyValueInfo.cpp
+++ lib/Analysis/LazyValueInfo.cpp
@@ -1516,11 +1516,15 @@
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();
+ if (Result.isConstant())
+ // We represent ConstantInt constants as constant ranges but other kinds
+ // of integer constants, i.e. ConstantExpr will be tagged as constants
+ assert(!isa<ConstantInt>(Result.getConstant()) &&
+ "ConstantInt value must be represented as constantrange");
return ConstantRange(Width, /*isFullSet=*/true);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23194.66918.patch
Type: text/x-patch
Size: 906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160805/d3737ead/attachment.bin>
More information about the llvm-commits
mailing list