This is an archive of the discontinued LLVM Phabricator instance.

[WIP][IPSCCP] Use PredInfo to propagate nonnull and hook it up to IPSCCP.
AbandonedPublic

Authored by fhahn on Aug 30 2018, 1:47 PM.

Details

Reviewers
efriedma
Summary

This is a POC patch to optimize code like below

int l = strlen(s); // s has nonnull attribute at call site.
if (!s) <-- remove this condition
    return -1;
return len;

The basic idea is to treat calls with !nonnull arguments like if we had something like assume arg != null at the call site.

This patch hacks up PredicateInfo to treat nonnull arguments at call
sites similar to assumes, it inserts a ssa_copy for the argument and
replaces all uses of the argument dominated by the call with the copy.
The copy has a predicate info attached stating that the copy is non
null.

The second part of the patch extends IPSCCP to use that information and
ValueLattice::getCompare() to simplify EQ comparisons of notconstant
with constant.

The most hacky part are the changes in PredicateInfo, but they should
be enough to highlight the idea.

Diff Detail

Event Timeline

fhahn created this revision.Aug 30 2018, 1:47 PM

This is not ready for review yet, I'll continue with this if D51505 is submitted.

fhahn planned changes to this revision.Oct 16 2018, 3:52 PM

This depends on D29011 via D51505

fhahn abandoned this revision.Nov 13 2018, 8:51 AM

I am abandoning this for now, as I updated D51431 to avoid adding nonnull, because even with freeze it would be too restrictive.