[PATCH] D104953: [ObjC][ARC] Prevent moving objc_retain calls past objc_release calls that release the retained object
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 1 02:38:15 PDT 2021
fhahn added a comment.
If we move a release past a retain, does this mean the retain/release pair is redundant? If that's the case, would it be easier to detect this case, during or after moving and then remove the redundant pair?
================
Comment at: llvm/test/Transforms/ObjCARC/code-motion.ll:43
+; Check that code motion is disabled.
+; Previously, ARC optimizer would move the release past the retain.
+
----------------
For this test, would be it be correct to move the `retain`/`release` calls to `%if.else`?
```
if.else:
call void @alterRefCount()
call i8* @llvm.objc.retain(i8* %[[OBJ]])
call void @use(i8* %obj)
call void @llvm.objc.release(i8* %[[OBJ]])
br label %join
```
================
Comment at: llvm/test/Transforms/ObjCARC/code-motion.ll:51
+
+; CHECK: define void @test3(i8* %[[OBJ:.*]], i1
+; CHECK-NEXT: call i8* @llvm.objc.retain(i8* %[[OBJ]])
----------------
Given that the function is quite small and the key here is to check precisely *if/where* the calls are moved, it would probably be good to create check lines for the whole function?
You could also pre-commit the tests, so the impact of the change is more obvious in the diff itself.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104953/new/
https://reviews.llvm.org/D104953
More information about the llvm-commits
mailing list