1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[ObjC][ARC] Fix a bug where the inline-asm retain/claim RV marker wasn't

inserted when the original call had a 'returned' argument

The code is testing whether the instruction BBI points to is the call
that is paired up with the retainRV/claimRV call, but it doesn't work
when the call has a 'returned' argument since GetArgRCIdentityRoot looks
through 'returned' arguments.

rdar://72485383
This commit is contained in:
Akira Hatanaka 2020-12-18 16:59:06 -08:00
parent a7e64248cb
commit 456368709d
2 changed files with 21 additions and 1 deletions

View File

@ -476,7 +476,7 @@ bool ObjCARCContract::tryToPeepholeInstruction(
--BBI;
} while (IsNoopInstruction(&*BBI));
if (&*BBI == GetArgRCIdentityRoot(Inst)) {
if (GetRCIdentityRoot(&*BBI) == GetArgRCIdentityRoot(Inst)) {
LLVM_DEBUG(dbgs() << "Adding inline asm marker for the return value "
"optimization.\n");
Changed = true;

View File

@ -32,11 +32,31 @@ entry:
ret void
}
; CHECK-LABEL: define i8* @foo3(
; CHECK: call i8* @returnsArg(
; CHECK-NEXT: call void asm sideeffect
define i8* @foo3(i8* %a) {
%call = call i8* @returnsArg(i8* %a)
call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %call)
ret i8* %call
}
; CHECK-LABEL: define i8* @foo4(
; CHECK: call i8* @returnsArg(
; CHECK-NEXT: call void asm sideeffect
define i8* @foo4(i8* %a) {
%call = call i8* @returnsArg(i8* %a)
call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %a)
ret i8* %call
}
declare i32* @qux()
declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
declare i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8*)
declare void @bar(i8*)
declare i8* @returnsArg(i8* returned)
!llvm.module.flags = !{!0}