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.