[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 22:14:27 PST 2017


inouehrs updated this revision to Diff 125886.
inouehrs added a comment.

addressed a comment from @sfertile


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 internal 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.125886.patch
Type: text/x-patch
Size: 1520 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171207/2ef9aa18/attachment.bin>


More information about the llvm-commits mailing list