This is an archive of the discontinued LLVM Phabricator instance.

[SCCP] Skip unknown values depending on tracked functions.
Needs ReviewPublic

Authored by fhahn on Feb 15 2020, 2:43 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

We do not resolve undefs for tracked functions in ResolvedUndefsIn. For
instructions that depend on results of tracked functions, we can skip
them in ResolvedUndefsIn, to avoid going to overdefined before we know
the function result. This allows us to cover a few more cases. This
should be safe; once we resolved the call result, we propagate it to all
users. Note that phis depending on tracked functions will still be
marked as overdefined early in some cases (e.g. loops).

Similarly, we can skip instructions depending on unknown function
arguments for tracked functions.

Before marking it as ready for review, I'd like to do some additional
testing.

Diff Detail

Event Timeline

fhahn created this revision.Feb 15 2020, 2:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2020, 2:43 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
jdoerfert added inline comments.
llvm/lib/Transforms/Scalar/SCCP.cpp
1446

Out of scope: Isn't branch on undef UB?

llvm/test/Transforms/SCCP/resolvedundefsin-tracked-fn.ll
1

Nit: You should probably do an NFC commit first to add the --function-signatures

fhahn marked 2 inline comments as done.Feb 16 2020, 3:48 AM
fhahn added inline comments.
llvm/lib/Transforms/Scalar/SCCP.cpp
1446

I don't think so. undef just indicates that the user of the value may receive an unspecified bit-patter'. IUUC we are only free to pick either the true/false destination, by replacing the condition with true/false. Note that we have to make sure we replace the undef if we make the assumption. If the branch on undef remains, the other branch might be (assumed as) taken, potentially leading to a contradiction further down the line.

Branches on poison values are UB.

llvm/test/Transforms/SCCP/resolvedundefsin-tracked-fn.ll
1

I'll do that. Initially I just tweaked the check lines to include the define, because update_test_checks.py defaults just check for the function name, causing FIleCheck to fail unexpectedly if the function is called before being defined.

I only just discovered --function-signature does what I want :)