1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

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

llvm-svn: 356707
This commit is contained in:
Akira Hatanaka 2019-03-21 20:16:09 +00:00
parent 3bd1a2cbe6
commit 9bfe38a556
2 changed files with 6 additions and 2 deletions

View File

@ -848,7 +848,7 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) {
// 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 "

View File

@ -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
}