This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] When a tail call is emitted in a block, stop translating it
ClosedPublic

Authored by paquette on Sep 10 2019, 2:05 PM.

Details

Summary

This fixes a crash in tail call translation caused by assume and lifetime_end intrinsics.

It's possible to have instructions other than a return after a tail call which will still have Analysis::isInTailCallPosition return true. (Namely, lifetime_end and assume intrinsics.)

If we emit a tail call instruction, we should stop translating instructions in the block. Otherwise, we can end up emitting an extra return, or dead instructions in general. This makes the verifier unhappy, and is generally unfortunate for codegen.

This also removes the code from AArch64CallLowering that checks if we have a tail call when lowering a return. This is covered by the new code now.

Also update call-translator-tail-call.ll to show that we now properly tail call in the presence of lifetime_end and assume.

Diff Detail

Event Timeline

paquette created this revision.Sep 10 2019, 2:05 PM
aemerson accepted this revision.Sep 10 2019, 4:25 PM

LGTM with nit.

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
1574

Assert here that HasTailCall == false?

This revision is now accepted and ready to land.Sep 10 2019, 4:25 PM
This revision was automatically updated to reflect the committed changes.