[PATCH] D43729: [CallSiteSplitting] do not split musttail calls
Fedor Indutny via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 24 11:28:40 PST 2018
indutny updated this revision to Diff 135801.
indutny added a comment.
Move condition to proper function.
https://reviews.llvm.org/D43729
Files:
lib/Transforms/Scalar/CallSiteSplitting.cpp
test/Transforms/CallSiteSplitting/musttail.ll
Index: test/Transforms/CallSiteSplitting/musttail.ll
===================================================================
--- /dev/null
+++ test/Transforms/CallSiteSplitting/musttail.ll
@@ -0,0 +1,19 @@
+; RUN: opt < %s -callsite-splitting -S
+
+define i8* @caller(i8* %a, i8* %b) {
+ %c = icmp eq i8* %a, null
+ br i1 %c, label %Tail, label %TBB
+TBB:
+ %c2 = icmp eq i8* %b, null
+ br i1 %c2, label %Tail, label %End
+Tail:
+ %ca = musttail call i8* @callee(i8* %a, i8* %b)
+ %cb = bitcast i8* %ca to i8*
+ ret i8* %cb
+End:
+ ret i8* null
+}
+
+define i8* @callee(i8* %a, i8* %b) noinline {
+ ret i8* %a
+}
Index: lib/Transforms/Scalar/CallSiteSplitting.cpp
===================================================================
--- lib/Transforms/Scalar/CallSiteSplitting.cpp
+++ lib/Transforms/Scalar/CallSiteSplitting.cpp
@@ -180,6 +180,14 @@
}
static bool canSplitCallSite(CallSite CS, TargetTransformInfo &TTI) {
+ // musttail calls can't be naively splitted. The split blocks must include
+ // not only the call instruction itself, but also (optional) bitcast and
+ // return instructions that follow it.
+ //
+ // TODO: Implement proper splitting
+ if (CS.isMustTailCall())
+ return false;
+
// FIXME: As of now we handle only CallInst. InvokeInst could be handled
// without too much effort.
Instruction *Instr = CS.getInstruction();
@@ -397,6 +405,7 @@
static bool tryToSplitCallSite(CallSite CS, TargetTransformInfo &TTI) {
if (!CS.arg_size() || !canSplitCallSite(CS, TTI))
return false;
+
return tryToSplitOnPredicatedArgument(CS) ||
tryToSplitOnPHIPredicatedArgument(CS);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43729.135801.patch
Type: text/x-patch
Size: 1639 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180224/e0fbdb74/attachment.bin>
More information about the llvm-commits
mailing list