[llvm] r356707 - Don't add a tail keyword to calls to ObjC runtime functions if the calls
Akira Hatanaka via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 21 13:16:09 PDT 2019
Author: ahatanak
Date: Thu Mar 21 13:16:09 2019
New Revision: 356707
URL: http://llvm.org/viewvc/llvm-project?rev=356707&view=rev
Log:
Don't add a tail keyword to calls to ObjC runtime functions if the calls
are annotated with notail.
r356705 annotated calls to objc_retainAutoreleasedReturnValue with
notail on x86-64. This commit teaches ARC optimizer to check the notail
marker on the call before turning it into a tail call.
rdar://problem/38675807
Modified:
llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/trunk/test/Transforms/ObjCARC/tail-call-invariant-enforcement.ll
Modified: llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp?rev=356707&r1=356706&r2=356707&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp (original)
+++ llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp Thu Mar 21 13:16:09 2019
@@ -848,7 +848,7 @@ void ObjCARCOpt::OptimizeIndividualCalls
// For functions which can never be passed stack arguments, add
// a tail keyword.
- if (IsAlwaysTail(Class)) {
+ if (IsAlwaysTail(Class) && !cast<CallInst>(Inst)->isNoTailCall()) {
Changed = true;
LLVM_DEBUG(
dbgs() << "Adding tail keyword to function since it can never be "
Modified: llvm/trunk/test/Transforms/ObjCARC/tail-call-invariant-enforcement.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ObjCARC/tail-call-invariant-enforcement.ll?rev=356707&r1=356706&r2=356707&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/ObjCARC/tail-call-invariant-enforcement.ll (original)
+++ llvm/trunk/test/Transforms/ObjCARC/tail-call-invariant-enforcement.ll Thu Mar 21 13:16:09 2019
@@ -48,10 +48,12 @@ entry:
ret i8* %x
}
-; Always tail call objc_retainAutoreleasedReturnValue.
+; Always tail call objc_retainAutoreleasedReturnValue unless it's annotated with
+; notail.
; CHECK: define i8* @test3(i8* %x) [[NUW]] {
; CHECK: %tmp0 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %y) [[NUW]]
; CHECK: %tmp1 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %z) [[NUW]]
+; CHECK: %tmp2 = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %z2) [[NUW]]
; CHECK: }
define i8* @test3(i8* %x) nounwind {
entry:
@@ -59,6 +61,8 @@ entry:
%tmp0 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %y)
%z = call i8* @tmp(i8* %x)
%tmp1 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %z)
+ %z2 = call i8* @tmp(i8* %x)
+ %tmp2 = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %z2)
ret i8* %x
}
More information about the llvm-commits
mailing list