From: Arnold Schwaighofer Date: Mon, 27 Nov 2017 19:03:40 +0000 (+0000) Subject: Inliner: Don't mark notail calls with the 'tail' attribute X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec3e9648821233f82e2caa02ed023e1b4a30de23;p=llvm 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319075 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 23a72e86e50..15a8bf22922 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -1850,7 +1850,8 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI, // 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(); diff --git a/test/Transforms/Inline/inline-tail.ll b/test/Transforms/Inline/inline-tail.ll index 66a6be7a59b..7b0fe57b68e 100644 --- a/test/Transforms/Inline/inline-tail.ll +++ b/test/Transforms/Inline/inline-tail.ll @@ -181,3 +181,18 @@ define i32 @test_mixedret_a(i1 zeroext %b) { %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 +}