[PATCH] D104953: [ObjC][ARC] Prevent moving objc_retain calls past objc_release calls that release the retained object
Akira Hatanaka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 1 17:27:04 PDT 2021
ahatanak added a comment.
The pair should be redundant if the release can be moved to the retain's insertion point. But I don't think removing the pair would be easier than just disabling code motion as doing so would require extra bookkeeping to keep track of the retain/release pairs that can be removed together. I think it's harder to get it right when the control flow isn't as simple as the tests in code-motion.ll.
================
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.
+
----------------
fhahn wrote:
> 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
> ```
It would be correct to move the pair to `%if.else`, but the retain cannot be moved past the call to `@alterRefCount` since that could cause `obj` to be deallocated before the call to `@use`.
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