[llvm] r319075 - Inliner: Don't mark notail calls with the 'tail' attribute
Arnold Schwaighofer via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 27 11:03:40 PST 2017
Author: arnolds
Date: Mon Nov 27 11:03:40 2017
New Revision: 319075
URL: http://llvm.org/viewvc/llvm-project?rev=319075&view=rev
Log:
Inliner: Don't mark notail calls with the 'tail' attribute
enum TailCallKind { TCK_None = 0, TCK_Tail = 1, TCK_MustTail = 2,
TCK_NoTail = 3 };
TCK_NoTail is greater than TCK_Tail so taking the min does not do the
correct thing.
rdar://35639547
Modified:
llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
llvm/trunk/test/Transforms/Inline/inline-tail.ll
Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=319075&r1=319074&r2=319075&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Nov 27 11:03:40 2017
@@ -1850,7 +1850,8 @@ bool llvm::InlineFunction(CallSite CS, I
// f -> g -> musttail f ==> f -> f
// f -> g -> tail f ==> f -> f
CallInst::TailCallKind ChildTCK = CI->getTailCallKind();
- ChildTCK = std::min(CallSiteTailKind, ChildTCK);
+ if (ChildTCK != CallInst::TCK_NoTail)
+ ChildTCK = std::min(CallSiteTailKind, ChildTCK);
CI->setTailCallKind(ChildTCK);
InlinedMustTailCalls |= CI->isMustTailCall();
Modified: llvm/trunk/test/Transforms/Inline/inline-tail.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/inline-tail.ll?rev=319075&r1=319074&r2=319075&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Inline/inline-tail.ll (original)
+++ llvm/trunk/test/Transforms/Inline/inline-tail.ll Mon Nov 27 11:03:40 2017
@@ -181,3 +181,18 @@ define i32 @test_mixedret_a(i1 zeroext %
%rv = musttail call i32 @test_mixedret_b(i1 zeroext %b)
ret i32 %rv
}
+
+declare i32 @donttailcall()
+
+define i32 @notail() {
+ %rv = notail call i32 @donttailcall()
+ ret i32 %rv
+}
+
+; CHECK: @test_notail
+; CHECK: notail call i32 @donttailcall
+; CHECK: ret
+define i32 @test_notail() {
+ %rv = tail call i32 @notail()
+ ret i32 %rv
+}
More information about the llvm-commits
mailing list