[PATCH] D40893: [PowerPC] fix a bug in TCO eligibility check
Hiroshi Inoue via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 6 05:18:12 PST 2017
inouehrs created this revision.
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 <https://github.com/google/brotli> failed in `make test` on PowerPC.
https://reviews.llvm.org/D40893
Files:
lib/Target/PowerPC/PPCISelLowering.cpp
test/CodeGen/PowerPC/ppc64-sibcall.ll
Index: test/CodeGen/PowerPC/ppc64-sibcall.ll
===================================================================
--- test/CodeGen/PowerPC/ppc64-sibcall.ll
+++ test/CodeGen/PowerPC/ppc64-sibcall.ll
@@ -41,6 +41,15 @@
; CHECK-SCO: b callee_64_64_copy
}
+define fastcc void @callee_64_64_copy_fastcc([8 x i64] %a, [8 x i64] %b) #0 { ret void }
+define void @caller_64_64_copy_ccc([8 x i64] %a, [8 x i64] %b) #1 {
+ tail call fastcc void @callee_64_64_copy_fastcc([8 x i64] %a, [8 x i64] %b)
+ ret void
+
+; CHECK-SCO-LABEL: caller_64_64_copy_ccc:
+; CHECK-SCO: bl callee_64_64_copy_fastcc
+}
+
define void @caller_64_64_reorder_copy([8 x i64] %a, [8 x i64] %b) #1 {
tail call void @callee_64_64_copy([8 x i64] %b, [8 x i64] %a)
ret void
Index: lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- lib/Target/PowerPC/PPCISelLowering.cpp
+++ lib/Target/PowerPC/PPCISelLowering.cpp
@@ -4443,6 +4443,12 @@
if (any_of(Outs, [](const ISD::OutputArg& OA) { return OA.Flags.isByVal(); }))
return false;
+ // If callee and caller use different calling conventions, we cannot pass
+ // parameters on stack since offsets for the parameter area may be different.
+ if (Caller->getCallingConv() != CalleeCC &&
+ needStackSlotPassParameters(Subtarget, Outs))
+ return false;
+
// No TCO/SCO on indirect call because Caller have to restore its TOC
if (!isFunctionGlobalAddress(Callee) &&
!isa<ExternalSymbolSDNode>(Callee))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40893.125711.patch
Type: text/x-patch
Size: 1511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171206/97f8169a/attachment.bin>
More information about the llvm-commits
mailing list