This is an archive of the discontinued LLVM Phabricator instance.

[LVI] Relax the assertion about LVILatticeVal type in getConstantRange
ClosedPublic

Authored by apilipenko on Aug 5 2016, 3:15 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

apilipenko updated this revision to Diff 66918.Aug 5 2016, 3:15 AM
apilipenko retitled this revision from to [LVI] Relax the assertion about LVILatticeVal type in getConstantRange.
apilipenko updated this object.
apilipenko added reviewers: regehr, reames.
apilipenko added a subscriber: llvm-commits.
apilipenko updated this revision to Diff 66929.Aug 5 2016, 5:00 AM

Upload the diff with full context.

apilipenko updated this object.Aug 8 2016, 8:59 AM
sanjoy accepted this revision.Aug 9 2016, 2:50 PM
sanjoy edited edge metadata.

lgtm with one nit inline

lib/Analysis/LazyValueInfo.cpp
1524 ↗(On Diff #66929)

I'd sink Result.isConstant() into the assert.

This revision is now accepted and ready to land.Aug 9 2016, 2:50 PM
This revision was automatically updated to reflect the committed changes.