[llvm-commits] [llvm] r152748 - in /llvm/trunk: lib/Transforms/Scalar/ObjCARC.cpp test/Transforms/ObjCARC/invoke.ll

Chris Lattner clattner at apple.com
Thu Mar 15 02:02:41 PDT 2012


On Mar 14, 2012, at 4:05 PM, Dan Gohman wrote:

> Author: djg
> Date: Wed Mar 14 18:05:06 2012
> New Revision: 152748
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=152748&view=rev
> Log:
> When an invoke is marked with metadata indicating its unwind edge
> should be ignored by ARC optimization, don't insert new ARC runtime
> calls in the unwind destination.

Hi Dan,

If this fixes PR12265, please close it.

-Chris

> 
> Modified:
>    llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp
>    llvm/trunk/test/Transforms/ObjCARC/invoke.ll
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp?rev=152748&r1=152747&r2=152748&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp Wed Mar 14 18:05:06 2012
> @@ -3041,7 +3041,8 @@
>       // but our releases will never depend on it, because they must be
>       // paired with retains from before the invoke.
>       InsertPts[0] = II->getNormalDest()->getFirstInsertionPt();
> -      InsertPts[1] = II->getUnwindDest()->getFirstInsertionPt();
> +      if (!II->getMetadata(NoObjCARCExceptionsMDKind))
> +        InsertPts[1] = II->getUnwindDest()->getFirstInsertionPt();
>     } else {
>       // Insert code immediately after the last use.
>       InsertPts[0] = llvm::next(BasicBlock::iterator(LastUse));
> 
> Modified: llvm/trunk/test/Transforms/ObjCARC/invoke.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ObjCARC/invoke.ll?rev=152748&r1=152747&r2=152748&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/ObjCARC/invoke.ll (original)
> +++ llvm/trunk/test/Transforms/ObjCARC/invoke.ll Wed Mar 14 18:05:06 2012
> @@ -2,6 +2,7 @@
> 
> declare i8* @objc_retain(i8*)
> declare void @objc_release(i8*)
> +declare i8* @objc_retainAutoreleasedReturnValue(i8*)
> declare i8* @objc_msgSend(i8*, i8*, ...)
> declare void @use_pointer(i8*)
> declare void @callee()
> @@ -68,6 +69,41 @@
>   ret void
> }
> 
> +; The optimizer should ignore invoke unwind paths consistently.
> +; PR12265
> +
> +; CHECK: define void @test2() {
> +; CHECK: invoke.cont:
> +; CHECK-NEXT: call i8* @objc_retain
> +; CHEK-NOT: @objc
> +; CHECK: finally.cont:
> +; CHECK-NEXT: call void @objc_release
> +; CHEK-NOT: @objc
> +; CHECK: finally.rethrow:
> +; CHEK-NOT: @objc
> +; CHECK: }
> +define void @test2() {
> +entry:
> +  %call = invoke i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* ()*)()
> +          to label %invoke.cont unwind label %finally.rethrow, !clang.arc.no_objc_arc_exceptions !0
> +
> +invoke.cont:                                      ; preds = %entry
> +  %tmp1 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %call) nounwind
> +  call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void ()*)(), !clang.arc.no_objc_arc_exceptions !0
> +  invoke void @use_pointer(i8* %call)
> +          to label %finally.cont unwind label %finally.rethrow, !clang.arc.no_objc_arc_exceptions !0
> +
> +finally.cont:                                     ; preds = %invoke.cont
> +  tail call void @objc_release(i8* %call) nounwind, !clang.imprecise_release !0
> +  ret void
> +
> +finally.rethrow:                                  ; preds = %invoke.cont, %entry
> +  %tmp2 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*)
> +          catch i8* null
> +  unreachable
> +}
> +
> declare i32 @__gxx_personality_v0(...)
> +declare i32 @__objc_personality_v0(...)
> 
> !0 = metadata !{}
> 
> 
> _______________________________________________
> 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