Page MenuHomePhabricator

[SCCP] Propagate inequalities

Authored by nikic on Jul 12 2020, 8:53 AM.



Teach SCCP to create notconstant lattice values from inequality comparisons and nonnull metadata, and update getConstant() to make use of them. Additionally isOverdefined() needs to be changed to consider notconstant an overdefined value.

Diff Detail

Event Timeline

nikic created this revision.Jul 12 2020, 8:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2020, 8:53 AM
efriedma added inline comments.Jul 13 2020, 2:16 PM

This is assuming branch on undef is UB, which other parts of LLVM still have issues with; see .

nikic planned changes to this revision.Thu, Jul 16, 12:26 PM

Okay, taking this off the queue for now. It should be noted though that we already perform this optimization in quite a few places (inequalities are recognized by LVI and thus optimized in JT/CVP and nonnull inequalities in particular are recognized by ValueTracking, and as such optimized all over the place.)

nikic updated this revision to Diff 280677.Sat, Jul 25, 7:07 AM

Restrict patch to MayIncludeUndef=false, which is metadata and assumes, but not comparisons. This puts the basic machinery in place, and will get fully enabled once the MayIncludeUndef flag for branches gets flipped.

fhahn accepted this revision.Sun, Aug 2, 2:13 PM

LGTM, thanks! I think avoiding this for branches for now should make us avoid PR46144, as we do in other places. Might be good to wait a day or so, in case Eli has further comments.

This revision is now accepted and ready to land.Sun, Aug 2, 2:13 PM
fhahn added a comment.Mon, Aug 3, 10:26 AM

I think we could also try to model dereferenced pointers as non-null with a new predicate. In particular, we could create ssa_copys for dereferenced pointers, attach a predicate and rename all dominated uses. Not sure how useful/expensive that would be though. Also, ideally we would want to rename all pointers to the same underlying object.

efriedma accepted this revision.Mon, Aug 3, 1:21 PM


This revision was automatically updated to reflect the committed changes.