This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] fix a bug in TCO eligibility check
ClosedPublic

Authored by inouehrs on Dec 6 2017, 5:18 AM.

Details

Summary

If the callee and caller use different calling convensions, we cannot apply TCO if the callee requires arguments on stack; e.g. C calling convention and Fast CC use the same registers for parameter passing, but the stack offset is not necessarily same.

Due to this problem, Brotli failed in make test on PowerPC.

This patch also recommit r319218 "[PowerPC] Allow tail calls of fastcc functions from C CallingConv functions." since the problem reported in r320106 should be fixed.

Diff Detail

Repository
rL LLVM

Event Timeline

inouehrs created this revision.Dec 6 2017, 5:18 AM
sfertile edited edge metadata.Dec 6 2017, 5:55 PM

Looks good to me.

test/CodeGen/PowerPC/ppc64-sibcall.ll
44 ↗(On Diff #125711)

We should add internal linkage here so the stack slot usage is the only thing blocking the tail-call.

inouehrs updated this revision to Diff 125886.Dec 6 2017, 10:14 PM

addressed a comment from @sfertile

inouehrs marked an inline comment as done.Dec 6 2017, 10:14 PM
echristo edited edge metadata.Dec 8 2017, 10:35 AM

Can you recombine this fix in with the patch that was reverted in r319218?

Thanks!

inouehrs updated this revision to Diff 126264.Dec 8 2017, 10:52 PM

combined with r319218 "[PowerPC] Allow tail calls of fastcc functions from C CallingConv functions."

combined with r319218 "[PowerPC] Allow tail calls of fastcc functions from C CallingConv functions."

Can you also update the patch description? One inline request as well. You can also handle the inline request as a separate commit.

Thanks!

-eric

lib/Target/PowerPC/PPCISelLowering.cpp
4442 ↗(On Diff #126264)

Since you're here can you update this with the actual problem and not an external link? We don't really do that.

inouehrs edited the summary of this revision. (Show Details)Dec 11 2017, 11:06 PM

Can you also update the patch description? One inline request as well. You can also handle the inline request as a separate commit.

I updated the description.

About the URL in the comment, it is an example of a case where GCC can do sibling call optimization even with a byval parameter rather tan an additional explanation on why this is a workaround; the example is too large to embed in a comment.
How about changing See: https://... to GCC can do such sibling call optimization such as https://... or just remove See: https://...? Any preference?
Anyway I like to touch up this comment later in another patch.

Can you also update the patch description? One inline request as well. You can also handle the inline request as a separate commit.

I updated the description.

About the URL in the comment, it is an example of a case where GCC can do sibling call optimization even with a byval parameter rather tan an additional explanation on why this is a workaround; the example is too large to embed in a comment.
How about changing See: https://... to GCC can do such sibling call optimization such as https://... or just remove See: https://...? Any preference?
Anyway I like to touch up this comment later in another patch.

What value is the link adding? Is it just the test case? If so:

  1. The test case is actually short enough for a comment, and
  2. You could generate IR from that test case and add it (with a FIXME note in the test case that we can do better).
lib/Target/PowerPC/PPCISelLowering.cpp
4400 ↗(On Diff #126264)

tail -> Tail

jtony added a comment.Dec 20 2017, 6:41 AM

LGTM.

lib/Target/PowerPC/PPCISelLowering.cpp
4408 ↗(On Diff #126264)

then->than

inouehrs updated this revision to Diff 128003.Dec 22 2017, 3:24 AM

updated comments

inouehrs marked 2 inline comments as done.Dec 22 2017, 3:25 AM
inouehrs added inline comments.
lib/Target/PowerPC/PPCISelLowering.cpp
4442 ↗(On Diff #126264)

How about this? I included the example in the URL here.

nemanjai accepted this revision.Dec 29 2017, 8:00 AM

LGTM

test/CodeGen/PowerPC/ppc64-sibcall.ll
44 ↗(On Diff #128003)

We aren't super strict about formatting in test cases, but please move the right brace to the next line.

45 ↗(On Diff #128003)

Please add a comment as to why we don't want to tail call here.

This revision is now accepted and ready to land.Dec 29 2017, 8:00 AM
This revision was automatically updated to reflect the committed changes.