This is an archive of the discontinued LLVM Phabricator instance.

Don't partially inline a musttail libcall.
ClosedPublic

Authored by babrath on Apr 5 2022, 3:50 AM.

Details

Summary

Partially inlining a libcall that has the musttail attribute leads to broken LLVM IR, triggering an assertion in the IR verifier. Compiling this file with -O2 -c should trigger the assertion. The proposed changes fix the issue, although I'm not 100% certain simply forgoing the optimization for musttail calls is the proper approach.

Diff Detail

Event Timeline

babrath created this revision.Apr 5 2022, 3:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 3:50 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
babrath edited the summary of this revision. (Show Details)Apr 5 2022, 3:57 AM
babrath edited the summary of this revision. (Show Details)
babrath edited the summary of this revision. (Show Details)
babrath published this revision for review.Apr 5 2022, 4:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 4:31 AM

Test?

Compiling the attached file with the mentioned flags triggers the assertion without the patch, and compiles correctly with the patch. Or does it need to come in a specific form? It's my first time suggesting a patch.

xbolva00 added a subscriber: xbolva00.EditedApr 5 2022, 5:25 AM

Some simple llc test for X86 (llvm/test/CodeGen/X86/) could work fine here:
https://godbolt.org/z/czTzMvx1r

; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s

babrath updated this revision to Diff 420490.Apr 5 2022, 6:48 AM
babrath edited the summary of this revision. (Show Details)

Adding test, using opt instead of llc.

lebedev.ri added inline comments.Apr 5 2022, 6:58 AM
llvm/test/Transforms/PartiallyInlineLibCalls/musttail.ll
1

Please put the file into X86/ dir, and use the utils/update_test_checks.py script to autogenerate check lines.

babrath updated this revision to Diff 420497.Apr 5 2022, 7:13 AM

Moving test to X86, updating with update_test_checks.py.

lebedev.ri accepted this revision.Apr 5 2022, 7:33 AM

LG.
Please specify the "Name <e@ma.il>" to be used for commit.

This revision is now accepted and ready to land.Apr 5 2022, 7:33 AM

LG.
Please specify the "Name <e@ma.il>" to be used for commit.

That would be "Bert Abrath <bert.abrath@UGent.be>". Unless I actually have to add that somewhere? Thanks for all the help :-)

This revision was landed with ongoing or failed builds.Apr 5 2022, 12:31 PM
This revision was automatically updated to reflect the committed changes.