This is an archive of the discontinued LLVM Phabricator instance.

CodeGenPrep: insert return after tail calls that return their arg.
Needs ReviewPublic

Authored by t.p.northover on Apr 11 2023, 7:16 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

When a call returns one of its arguments this is considered a cast by stripPointerCasts. So IR returning that directly from a tail call (which should be fine) can become muddied and seem to return an argument from earlier in the function.

This adds some simple checks to spot this situation and reclassify it as the original "tail call -> phi -> return" dataflow.

Diff Detail

Event Timeline

t.p.northover created this revision.Apr 11 2023, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 7:16 AM
t.p.northover requested review of this revision.Apr 11 2023, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 7:16 AM
nikic added a subscriber: nikic.Apr 11 2023, 7:26 AM

Possibly we should just drop the stripPointerCasts()? This is probably just not relevant anymore with opaque pointers.