This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Don't strip function type casts from musttail calls
ClosedPublic

Authored by rnk on Apr 2 2018, 1:51 PM.

Details

Summary

The cast simplifications that instcombine does here do not make any
attempt to obey the verifier rules for musttail calls. Therefore we have
to disable them.

Diff Detail

Repository
rL LLVM

Event Timeline

rnk created this revision.Apr 2 2018, 1:51 PM
efriedma added inline comments.Apr 2 2018, 2:37 PM
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
4011 ↗(On Diff #140687)

Why does it matter whether the function is a thunk? It seems like this would be a problem for any musttail call.

rnk added inline comments.Apr 2 2018, 3:13 PM
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
4011 ↗(On Diff #140687)

That's true. I can imagine LTO situations where this would go wrong without any variadic argument pack forwarding being involved.

rnk retitled this revision from [InstCombine] Don't optimize call target casts inside thunks to [InstCombine] Don't strip function type casts from musttail calls.Apr 2 2018, 3:27 PM
rnk edited the summary of this revision. (Show Details)
rnk updated this revision to Diff 140698.Apr 2 2018, 3:34 PM
  • this isn't about thunks
rnk updated this revision to Diff 140699.Apr 2 2018, 3:36 PM
  • rebase over committed changes
efriedma accepted this revision.Apr 2 2018, 3:44 PM

LGTM with one minor change.

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
4012 ↗(On Diff #140699)

CS.isMustTailCall().

This revision is now accepted and ready to land.Apr 2 2018, 3:44 PM
rnk added inline comments.Apr 2 2018, 3:47 PM
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
4012 ↗(On Diff #140699)

Thanks!

This revision was automatically updated to reflect the committed changes.