This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Fix nomerge attribute not working in tail calls.
ClosedPublic

Authored by zequanwu on Mar 23 2023, 11:50 AM.

Details

Summary

In D79537, nomerge was made to only apply to non-tail calls. This fixes it by also applying it to tail calls.

For ARM, I only made the new MI to inherit the flag under TCRETURNdi and TCRETURNri, because that's the place tail calls got replaced. Not sure if there's any other place needed.

Fixes #61545.

Diff Detail

Event Timeline

zequanwu created this revision.Mar 23 2023, 11:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 11:50 AM
zequanwu requested review of this revision.Mar 23 2023, 11:50 AM
hans added a comment.Mar 27 2023, 2:39 AM

Looks good as far as I can tell, but hopefully Craig who knows backends better can also take a look.

Maybe add to the description that this is a follow-up to D79537 which extends support to tail calls. (And do we need to do something for globalisel, or can that be left as a todo?)

zequanwu edited the summary of this revision. (Show Details)Mar 27 2023, 7:54 AM

(And do we need to do something for globalisel, or can that be left as a todo?)

I don't know about globalisel. For the repro, this patch fixes that.

craig.topper added inline comments.Mar 27 2023, 9:49 AM
llvm/test/CodeGen/AArch64/nomerge.ll
23

This should be in the body of the @foo_tail function. Did you run utils/update_llc_test_checks.py?

llvm/test/CodeGen/ARM/nomerge.ll
69

These should be in the body of @foo_tail

zequanwu updated this revision to Diff 508725.Mar 27 2023, 10:16 AM
zequanwu marked 2 inline comments as done.

Update all tests by running llvm/utils/update_llc_test_checks.py.

zequanwu added inline comments.Mar 27 2023, 10:17 AM
llvm/test/CodeGen/AArch64/nomerge.ll
23

Updated. I didn't realize those CHECKs were generated by the script.

jrtc27 added inline comments.Apr 3 2023, 8:56 AM
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
6301

Leave whitespace not in the code you're touching alone

llvm/test/CodeGen/AArch64/nomerge.ll
22

Where did this come from?

41

Precommit all these?

llvm/test/CodeGen/ARM/nomerge.ll
2

This conversion should likely be precommitted to highlight the actual diff

llvm/test/CodeGen/RISCV/nomerge.ll
2

Ugh, D79537 added this without getting a RISC-V contributor's review (Craig wasn't yet one)... like the others, convert this separately

8

These tests could benefit from nounwind to trim irrelevant CFI directives

zequanwu updated this revision to Diff 510539.Apr 3 2023, 9:45 AM
zequanwu marked 3 inline comments as done.
  • Reverted white spaces changes.
  • Add nounwind for tests to trim CFI directives.
llvm/test/CodeGen/AArch64/nomerge.ll
41

Can you elaborate on what does precommit mean? Do you mean commit on foo_tail functions without CHECKs before this patch?

jrtc27 added inline comments.Apr 3 2023, 9:47 AM
llvm/test/CodeGen/AArch64/nomerge.ll
41

Commit the tests with CHECK lines generated from the compiler without this codegen change applied

zequanwu updated this revision to Diff 510870.Apr 4 2023, 11:43 AM
zequanwu marked 4 inline comments as done.

Rebase.

llvm/test/CodeGen/AArch64/nomerge.ll
41
jrtc27 added inline comments.Apr 11 2023, 9:25 AM
llvm/test/CodeGen/RISCV/nomerge.ll
42–67

?

zequanwu updated this revision to Diff 512492.Apr 11 2023, 9:28 AM
zequanwu marked an inline comment as done.

Address comment.

zequanwu added a reviewer: rnk.May 9 2023, 1:49 PM
rnk accepted this revision.May 10 2023, 11:08 AM

This looks good to me.

I thought perhaps it would be shorter and simpler to have addNoMergeInfo take and return the SDValue which is being marked to avoid the need for new SDValue variables, but I don't think that's essential.

@jrtc27 , are your concerns addressed?

Regarding globalisel, @zequanwu , can you file an issue for implementing nomerge support in globalisel? It's probably easiest to construct an example with the AArch64 backend.

This revision is now accepted and ready to land.May 10 2023, 11:08 AM

This looks good to me.

I thought perhaps it would be shorter and simpler to have addNoMergeInfo take and return the SDValue which is being marked to avoid the need for new SDValue variables, but I don't think that's essential.

@jrtc27 , are your concerns addressed?

Regarding globalisel, @zequanwu , can you file an issue for implementing nomerge support in globalisel? It's probably easiest to construct an example with the AArch64 backend.

Yes, the tests are much cleaner now, both in content and in reviewability of the diff, thanks.

Regarding globalisel, @zequanwu , can you file an issue for implementing nomerge support in globalisel? It's probably easiest to construct an example with the AArch64 backend.

Filed at https://github.com/llvm/llvm-project/issues/62641

This revision was landed with ongoing or failed builds.May 10 2023, 11:25 AM
This revision was automatically updated to reflect the committed changes.