2011-06-17 04:57:14 +08:00
|
|
|
; RUN: opt -S -objc-arc < %s | FileCheck %s
|
|
|
|
|
|
|
|
declare i8* @objc_retain(i8*)
|
|
|
|
declare void @objc_release(i8*)
|
2012-03-15 07:05:06 +08:00
|
|
|
declare i8* @objc_retainAutoreleasedReturnValue(i8*)
|
2011-06-17 04:57:14 +08:00
|
|
|
declare i8* @objc_msgSend(i8*, i8*, ...)
|
|
|
|
declare void @use_pointer(i8*)
|
|
|
|
declare void @callee()
|
2012-03-24 02:09:00 +08:00
|
|
|
declare i8* @returner()
|
2011-06-17 04:57:14 +08:00
|
|
|
|
|
|
|
; ARCOpt shouldn't try to move the releases to the block containing the invoke.
|
|
|
|
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define void @test0(
|
2011-06-17 04:57:14 +08:00
|
|
|
; CHECK: invoke.cont:
|
2013-02-22 17:09:42 +08:00
|
|
|
; CHECK: call void @objc_release(i8* %zipFile) [[NUW:#[0-9]+]], !clang.imprecise_release !0
|
2011-06-17 04:57:14 +08:00
|
|
|
; CHECK: ret void
|
|
|
|
; CHECK: lpad:
|
2013-02-22 17:09:42 +08:00
|
|
|
; CHECK: call void @objc_release(i8* %zipFile) [[NUW]], !clang.imprecise_release !0
|
2011-06-17 04:57:14 +08:00
|
|
|
; CHECK: ret void
|
2013-04-27 13:25:54 +08:00
|
|
|
; CHECK-NEXT: }
|
2015-06-18 04:52:32 +08:00
|
|
|
define void @test0(i8* %zipFile) personality i32 (...)* @__gxx_personality_v0 {
|
2011-06-17 04:57:14 +08:00
|
|
|
entry:
|
|
|
|
call i8* @objc_retain(i8* %zipFile) nounwind
|
|
|
|
call void @use_pointer(i8* %zipFile)
|
|
|
|
invoke void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*)*)(i8* %zipFile)
|
|
|
|
to label %invoke.cont unwind label %lpad
|
|
|
|
|
|
|
|
invoke.cont: ; preds = %entry
|
|
|
|
call void @objc_release(i8* %zipFile) nounwind, !clang.imprecise_release !0
|
|
|
|
ret void
|
|
|
|
|
|
|
|
lpad: ; preds = %entry
|
2015-06-18 04:52:32 +08:00
|
|
|
%exn = landingpad {i8*, i32}
|
2011-09-01 05:04:11 +08:00
|
|
|
cleanup
|
2011-06-17 04:57:14 +08:00
|
|
|
call void @objc_release(i8* %zipFile) nounwind, !clang.imprecise_release !0
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; ARCOpt should move the release before the callee calls.
|
|
|
|
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define void @test1(
|
2011-06-17 04:57:14 +08:00
|
|
|
; CHECK: invoke.cont:
|
2013-02-22 17:09:42 +08:00
|
|
|
; CHECK: call void @objc_release(i8* %zipFile) [[NUW]], !clang.imprecise_release !0
|
2011-06-17 04:57:14 +08:00
|
|
|
; CHECK: call void @callee()
|
|
|
|
; CHECK: br label %done
|
|
|
|
; CHECK: lpad:
|
2013-02-22 17:09:42 +08:00
|
|
|
; CHECK: call void @objc_release(i8* %zipFile) [[NUW]], !clang.imprecise_release !0
|
2011-06-17 04:57:14 +08:00
|
|
|
; CHECK: call void @callee()
|
|
|
|
; CHECK: br label %done
|
|
|
|
; CHECK: done:
|
|
|
|
; CHECK-NEXT: ret void
|
2013-04-27 13:25:54 +08:00
|
|
|
; CHECK-NEXT: }
|
2015-06-18 04:52:32 +08:00
|
|
|
define void @test1(i8* %zipFile) personality i32 (...)* @__gxx_personality_v0 {
|
2011-06-17 04:57:14 +08:00
|
|
|
entry:
|
|
|
|
call i8* @objc_retain(i8* %zipFile) nounwind
|
|
|
|
call void @use_pointer(i8* %zipFile)
|
|
|
|
invoke void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*)*)(i8* %zipFile)
|
|
|
|
to label %invoke.cont unwind label %lpad
|
|
|
|
|
|
|
|
invoke.cont: ; preds = %entry
|
|
|
|
call void @callee()
|
|
|
|
br label %done
|
|
|
|
|
|
|
|
lpad: ; preds = %entry
|
2015-06-18 04:52:32 +08:00
|
|
|
%exn = landingpad {i8*, i32}
|
2011-09-01 05:04:11 +08:00
|
|
|
cleanup
|
2011-06-17 04:57:14 +08:00
|
|
|
call void @callee()
|
|
|
|
br label %done
|
|
|
|
|
|
|
|
done:
|
|
|
|
call void @objc_release(i8* %zipFile) nounwind, !clang.imprecise_release !0
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2012-03-15 07:05:06 +08:00
|
|
|
; The optimizer should ignore invoke unwind paths consistently.
|
|
|
|
; PR12265
|
|
|
|
|
2015-06-18 04:52:32 +08:00
|
|
|
; CHECK: define void @test2() personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*) {
|
2012-03-15 07:05:06 +08:00
|
|
|
; CHECK: invoke.cont:
|
|
|
|
; CHECK-NEXT: call i8* @objc_retain
|
2012-08-17 20:28:26 +08:00
|
|
|
; CHECK-NOT: @objc_r
|
2012-03-15 07:05:06 +08:00
|
|
|
; CHECK: finally.cont:
|
|
|
|
; CHECK-NEXT: call void @objc_release
|
2012-08-17 20:28:26 +08:00
|
|
|
; CHECK-NOT: @objc
|
2012-03-15 07:05:06 +08:00
|
|
|
; CHECK: finally.rethrow:
|
2012-08-17 20:28:26 +08:00
|
|
|
; CHECK-NOT: @objc
|
2012-03-15 07:05:06 +08:00
|
|
|
; CHECK: }
|
2015-06-18 04:52:32 +08:00
|
|
|
define void @test2() personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*) {
|
2012-03-15 07:05:06 +08:00
|
|
|
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
|
2015-06-18 04:52:32 +08:00
|
|
|
%tmp2 = landingpad { i8*, i32 }
|
2012-03-15 07:05:06 +08:00
|
|
|
catch i8* null
|
|
|
|
unreachable
|
|
|
|
}
|
|
|
|
|
2012-03-24 01:47:54 +08:00
|
|
|
; Don't try to place code on invoke critical edges.
|
|
|
|
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define void @test3(
|
2012-03-24 01:47:54 +08:00
|
|
|
; CHECK: if.end:
|
2013-02-22 17:09:42 +08:00
|
|
|
; CHECK-NEXT: call void @objc_release(i8* %p) [[NUW]]
|
2012-03-24 01:47:54 +08:00
|
|
|
; CHECK-NEXT: ret void
|
2013-04-27 13:25:54 +08:00
|
|
|
; CHECK-NEXT: }
|
2015-06-18 04:52:32 +08:00
|
|
|
define void @test3(i8* %p, i1 %b) personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*) {
|
2012-03-24 01:47:54 +08:00
|
|
|
entry:
|
|
|
|
%0 = call i8* @objc_retain(i8* %p)
|
|
|
|
call void @callee()
|
|
|
|
br i1 %b, label %if.else, label %if.then
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
invoke void @use_pointer(i8* %p)
|
|
|
|
to label %if.end unwind label %lpad, !clang.arc.no_objc_arc_exceptions !0
|
|
|
|
|
|
|
|
if.else:
|
|
|
|
invoke void @use_pointer(i8* %p)
|
|
|
|
to label %if.end unwind label %lpad, !clang.arc.no_objc_arc_exceptions !0
|
|
|
|
|
|
|
|
lpad:
|
2015-06-18 04:52:32 +08:00
|
|
|
%r = landingpad { i8*, i32 }
|
2012-03-24 01:47:54 +08:00
|
|
|
cleanup
|
|
|
|
ret void
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
call void @objc_release(i8* %p)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Like test3, but with ARC-relevant exception handling.
|
|
|
|
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define void @test4(
|
2012-03-24 01:47:54 +08:00
|
|
|
; CHECK: lpad:
|
2015-06-18 04:52:32 +08:00
|
|
|
; CHECK-NEXT: %r = landingpad { i8*, i32 }
|
2012-03-24 01:47:54 +08:00
|
|
|
; CHECK-NEXT: cleanup
|
2013-02-22 17:09:42 +08:00
|
|
|
; CHECK-NEXT: call void @objc_release(i8* %p) [[NUW]]
|
2012-03-24 01:47:54 +08:00
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
; CHECK: if.end:
|
2013-02-22 17:09:42 +08:00
|
|
|
; CHECK-NEXT: call void @objc_release(i8* %p) [[NUW]]
|
2012-03-24 01:47:54 +08:00
|
|
|
; CHECK-NEXT: ret void
|
2013-04-27 13:25:54 +08:00
|
|
|
; CHECK-NEXT: }
|
2015-06-18 04:52:32 +08:00
|
|
|
define void @test4(i8* %p, i1 %b) personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*) {
|
2012-03-24 01:47:54 +08:00
|
|
|
entry:
|
|
|
|
%0 = call i8* @objc_retain(i8* %p)
|
|
|
|
call void @callee()
|
|
|
|
br i1 %b, label %if.else, label %if.then
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
invoke void @use_pointer(i8* %p)
|
|
|
|
to label %if.end unwind label %lpad
|
|
|
|
|
|
|
|
if.else:
|
|
|
|
invoke void @use_pointer(i8* %p)
|
|
|
|
to label %if.end unwind label %lpad
|
|
|
|
|
|
|
|
lpad:
|
2015-06-18 04:52:32 +08:00
|
|
|
%r = landingpad { i8*, i32 }
|
2012-03-24 01:47:54 +08:00
|
|
|
cleanup
|
|
|
|
call void @objc_release(i8* %p)
|
|
|
|
ret void
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
call void @objc_release(i8* %p)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2012-03-24 02:09:00 +08:00
|
|
|
; Don't turn the retainAutoreleaseReturnValue into retain, because it's
|
|
|
|
; for an invoke which we can assume codegen will put immediately prior.
|
|
|
|
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define void @test5(
|
2012-03-24 02:09:00 +08:00
|
|
|
; CHECK: call i8* @objc_retainAutoreleasedReturnValue(i8* %z)
|
|
|
|
; CHECK: }
|
2015-06-18 04:52:32 +08:00
|
|
|
define void @test5() personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*) {
|
2012-03-24 02:09:00 +08:00
|
|
|
entry:
|
|
|
|
%z = invoke i8* @returner()
|
|
|
|
to label %if.end unwind label %lpad, !clang.arc.no_objc_arc_exceptions !0
|
|
|
|
|
|
|
|
lpad:
|
2015-06-18 04:52:32 +08:00
|
|
|
%r13 = landingpad { i8*, i32 }
|
2012-03-24 02:09:00 +08:00
|
|
|
cleanup
|
|
|
|
ret void
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
call i8* @objc_retainAutoreleasedReturnValue(i8* %z)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Like test5, but there's intervening code.
|
|
|
|
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define void @test6(
|
2012-03-24 02:09:00 +08:00
|
|
|
; CHECK: call i8* @objc_retain(i8* %z)
|
|
|
|
; CHECK: }
|
2015-06-18 04:52:32 +08:00
|
|
|
define void @test6() personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*) {
|
2012-03-24 02:09:00 +08:00
|
|
|
entry:
|
|
|
|
%z = invoke i8* @returner()
|
|
|
|
to label %if.end unwind label %lpad, !clang.arc.no_objc_arc_exceptions !0
|
|
|
|
|
|
|
|
lpad:
|
2015-06-18 04:52:32 +08:00
|
|
|
%r13 = landingpad { i8*, i32 }
|
2012-03-24 02:09:00 +08:00
|
|
|
cleanup
|
|
|
|
ret void
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
call void @callee()
|
|
|
|
call i8* @objc_retainAutoreleasedReturnValue(i8* %z)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2011-09-01 05:04:11 +08:00
|
|
|
declare i32 @__gxx_personality_v0(...)
|
2012-03-15 07:05:06 +08:00
|
|
|
declare i32 @__objc_personality_v0(...)
|
2011-09-01 05:04:11 +08:00
|
|
|
|
2013-02-22 17:09:42 +08:00
|
|
|
; CHECK: attributes [[NUW]] = { nounwind }
|
|
|
|
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
|
|
|
!0 = !{}
|