[PATCH] D23441: [ppc64] Don't apply sibling call optimization if callee has any byval arg
Chuang-Yu Cheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 12 02:17:04 PDT 2016
cycheng created this revision.
cycheng added reviewers: hfinkel, kbarton, nemanjai, amehsan.
cycheng added subscribers: llvm-commits, tjablin.
Herald added a subscriber: nemanjai.
This is a quick work around, because in some situations, e.g. caller's stack size > callee's stack size, we are still able to apply sibling call optimization even callee has byval arg.
This patch fix: https://llvm.org/bugs/show_bug.cgi?id=28328
https://reviews.llvm.org/D23441
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
@@ -189,3 +189,15 @@
; CHECK-SCO-LABEL: w_caller:
; CHECK-SCO: bl w_callee
}
+
+%struct.byvalTest = type { [8 x i8] }
+ at byval = common global %struct.byvalTest zeroinitializer
+
+define void @byval_callee(%struct.byvalTest* byval %ptr) { ret void }
+define void @byval_caller() {
+ tail call void @byval_callee(%struct.byvalTest* byval @byval)
+ ret void
+
+; CHECK-SCO-LABEL: bl byval_callee
+; CHECK-SCO: bl byval_callee
+}
Index: lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- lib/Target/PowerPC/PPCISelLowering.cpp
+++ lib/Target/PowerPC/PPCISelLowering.cpp
@@ -3964,11 +3964,16 @@
if (CalleeCC != CallingConv::Fast && CalleeCC != CallingConv::C)
return false;
- // Functions containing by val parameters are not supported.
+ // Caller contains any byval parameter is not supported.
if (std::any_of(Ins.begin(), Ins.end(),
[](const ISD::InputArg& IA) { return IA.Flags.isByVal(); }))
return false;
+ // Callee contains any byval parameter is not supported, too.
+ if (std::any_of(Outs.begin(), Outs.end(),
+ [](const ISD::OutputArg& OA) { return OA.Flags.isByVal(); }))
+ 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: D23441.67803.patch
Type: text/x-patch
Size: 1580 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160812/1fca8f9c/attachment.bin>
More information about the llvm-commits
mailing list