[llvm] ffd982f - [ObjC][ARC] Fix a bug where the inline-asm retain/claim RV marker wasn't
Akira Hatanaka via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 18 16:59:35 PST 2020
Author: Akira Hatanaka
Date: 2020-12-18T16:59:06-08:00
New Revision: ffd982f7db58acf6653f987ca6411712feea25c3
URL: https://github.com/llvm/llvm-project/commit/ffd982f7db58acf6653f987ca6411712feea25c3
DIFF: https://github.com/llvm/llvm-project/commit/ffd982f7db58acf6653f987ca6411712feea25c3.diff
LOG: [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
Added:
Modified:
llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
llvm/test/Transforms/ObjCARC/contract-marker.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
index e190c46b613b..c2499fc85cf5 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
@@ -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;
diff --git a/llvm/test/Transforms/ObjCARC/contract-marker.ll b/llvm/test/Transforms/ObjCARC/contract-marker.ll
index a93bbe3a2901..e2217068d5d1 100644
--- a/llvm/test/Transforms/ObjCARC/contract-marker.ll
+++ b/llvm/test/Transforms/ObjCARC/contract-marker.ll
@@ -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}
More information about the llvm-commits
mailing list