[llvm-commits] [llvm] r157080 - in /llvm/trunk: lib/Transforms/Scalar/ObjCARC.cpp test/Transforms/ObjCARC/weak-dce.ll
Bob Wilson
bob.wilson at apple.com
Fri May 18 17:24:22 PDT 2012
On May 18, 2012, at 3:17 PM, Dan Gohman <gohman at apple.com> wrote:
> Author: djg
> Date: Fri May 18 17:17:29 2012
> New Revision: 157080
>
> URL: http://llvm.org/viewvc/llvm-project?rev=157080&view=rev
> Log:
> Fix replacing all the users of objc weak runtime routines
> when deleting them. rdar://11434915.
>
> Added:
> llvm/trunk/test/Transforms/ObjCARC/weak-dce.ll
> Modified:
> llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp?rev=157080&r1=157079&r2=157080&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp Fri May 18 17:17:29 2012
> @@ -3486,8 +3486,18 @@
> for (Value::use_iterator UI = Alloca->use_begin(),
> UE = Alloca->use_end(); UI != UE; ) {
> CallInst *UserInst = cast<CallInst>(*UI++);
> - if (!UserInst->use_empty())
> - UserInst->replaceAllUsesWith(UserInst->getArgOperand(0));
> + switch (GetBasicInstructionClass(UserInst)) {
> + case IC_InitWeak:
> + case IC_StoreWeak:
> + // These functions return their second argument.
> + UserInst->replaceAllUsesWith(UserInst->getArgOperand(1));
> + break;
> + case IC_DestroyWeak:
> + // No return value.
> + break;
> + default:
> + break;
> + }
In the default case, the previous code did an RAUW with operand 0, but it now does nothing at all. Is that really what you intended?
> UserInst->eraseFromParent();
> }
> Alloca->eraseFromParent();
>
> Added: llvm/trunk/test/Transforms/ObjCARC/weak-dce.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ObjCARC/weak-dce.ll?rev=157080&view=auto
> ==============================================================================
> --- llvm/trunk/test/Transforms/ObjCARC/weak-dce.ll (added)
> +++ llvm/trunk/test/Transforms/ObjCARC/weak-dce.ll Fri May 18 17:17:29 2012
> @@ -0,0 +1,46 @@
> +; RUN: opt -S -basicaa -objc-arc < %s | FileCheck %s
> +; rdar://11434915
> +
> +; Delete the weak calls and replace them with just the net retain.
> +
> +; CHECK: define void @test0(i8* %p) {
> +; CHECK-NEXT: call i8* @objc_retain(i8* %p)
> +; CHECK-NEXT: ret void
> +
> +define void @test0(i8* %p) {
> + %weakBlock = alloca i8*, align 8
> + %tmp7 = call i8* @objc_initWeak(i8** %weakBlock, i8* %p) nounwind
> + %tmp26 = call i8* @objc_loadWeakRetained(i8** %weakBlock) nounwind
> + call void @objc_destroyWeak(i8** %weakBlock) nounwind
> + ret void
> +}
> +
> +; CHECK: define i8* @test1(i8* %p) {
> +; CHECK-NEXT: call i8* @objc_retain(i8* %p)
> +; CHECK-NEXT: ret i8* %p
> +
> +define i8* @test1(i8* %p) {
> + %weakBlock = alloca i8*, align 8
> + %tmp7 = call i8* @objc_initWeak(i8** %weakBlock, i8* %p) nounwind
> + %tmp26 = call i8* @objc_loadWeakRetained(i8** %weakBlock) nounwind
> + call void @objc_destroyWeak(i8** %weakBlock) nounwind
> + ret i8* %tmp26
> +}
> +
> +; CHECK: define i8* @test2(i8* %p, i8* %q) {
> +; CHECK-NEXT: call i8* @objc_retain(i8* %q)
> +; CHECK-NEXT: ret i8* %q
> +
> +define i8* @test2(i8* %p, i8* %q) {
> + %weakBlock = alloca i8*, align 8
> + %tmp7 = call i8* @objc_initWeak(i8** %weakBlock, i8* %p) nounwind
> + %tmp19 = call i8* @objc_storeWeak(i8** %weakBlock, i8* %q) nounwind
> + %tmp26 = call i8* @objc_loadWeakRetained(i8** %weakBlock) nounwind
> + call void @objc_destroyWeak(i8** %weakBlock) nounwind
> + ret i8* %tmp26
> +}
> +
> +declare i8* @objc_initWeak(i8**, i8*)
> +declare void @objc_destroyWeak(i8**)
> +declare i8* @objc_loadWeakRetained(i8**)
> +declare i8* @objc_storeWeak(i8** %weakBlock, i8* %q)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list