2011-06-16 07:37:01 +08:00
|
|
|
; RUN: opt -objc-arc-contract -S < %s | FileCheck %s
|
|
|
|
; rdar://9511608
|
|
|
|
|
|
|
|
%0 = type opaque
|
|
|
|
%1 = type opaque
|
|
|
|
%2 = type { i64, i64 }
|
|
|
|
%4 = type opaque
|
|
|
|
|
|
|
|
declare %0* @"\01-[NSAttributedString(Terminal) pathAtIndex:effectiveRange:]"(%1*, i8* nocapture, i64, %2*) optsize
|
|
|
|
declare i8* @objc_retainAutoreleasedReturnValue(i8*)
|
2012-06-26 03:47:37 +08:00
|
|
|
declare i8* @objc_msgSend_fixup(i8*, i8*, ...)
|
|
|
|
declare i8* @objc_msgSend(i8*, i8*, ...)
|
2011-06-16 07:37:01 +08:00
|
|
|
declare void @objc_release(i8*)
|
|
|
|
declare %2 @NSUnionRange(i64, i64, i64, i64) optsize
|
|
|
|
declare i8* @objc_autoreleaseReturnValue(i8*)
|
|
|
|
declare i8* @objc_autorelease(i8*)
|
2012-06-26 03:47:37 +08:00
|
|
|
declare i32 @__gxx_personality_sj0(...)
|
2011-06-16 07:37:01 +08:00
|
|
|
|
|
|
|
; Don't get in trouble on bugpointed code.
|
|
|
|
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define void @test0(
|
2011-06-16 07:37:01 +08:00
|
|
|
define void @test0() {
|
|
|
|
bb:
|
|
|
|
%tmp = bitcast %4* undef to i8*
|
|
|
|
%tmp1 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %tmp) nounwind
|
|
|
|
br label %bb3
|
|
|
|
|
|
|
|
bb3: ; preds = %bb2
|
|
|
|
br i1 undef, label %bb6, label %bb4
|
|
|
|
|
|
|
|
bb4: ; preds = %bb3
|
|
|
|
switch i64 undef, label %bb5 [
|
|
|
|
i64 9223372036854775807, label %bb6
|
|
|
|
i64 0, label %bb6
|
|
|
|
]
|
|
|
|
|
|
|
|
bb5: ; preds = %bb4
|
|
|
|
br label %bb6
|
|
|
|
|
|
|
|
bb6: ; preds = %bb5, %bb4, %bb4, %bb3
|
|
|
|
%tmp7 = phi %4* [ undef, %bb5 ], [ undef, %bb4 ], [ undef, %bb3 ], [ undef, %bb4 ]
|
|
|
|
unreachable
|
|
|
|
}
|
|
|
|
|
|
|
|
; When rewriting operands for a phi which has multiple operands
|
|
|
|
; for the same block, use the exactly same value in each block.
|
|
|
|
|
2013-07-14 09:50:49 +08:00
|
|
|
; CHECK-LABEL: define void @test1(
|
2011-06-16 07:37:01 +08:00
|
|
|
; CHECK: %0 = bitcast i8* %tmp3 to %0*
|
|
|
|
; CHECK: br i1 undef, label %bb7, label %bb7
|
|
|
|
; CHECK: bb7:
|
|
|
|
; CHECK: %tmp8 = phi %0* [ %0, %bb ], [ %0, %bb ]
|
2013-04-27 13:25:54 +08:00
|
|
|
; CHECK: }
|
2011-06-16 07:37:01 +08:00
|
|
|
define void @test1() {
|
|
|
|
bb:
|
2012-06-26 03:47:37 +08:00
|
|
|
%tmp = tail call %0* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %0* ()*)()
|
2011-06-16 07:37:01 +08:00
|
|
|
%tmp2 = bitcast %0* %tmp to i8*
|
|
|
|
%tmp3 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %tmp2) nounwind
|
|
|
|
br i1 undef, label %bb7, label %bb7
|
|
|
|
|
|
|
|
bb7: ; preds = %bb6, %bb6, %bb5
|
|
|
|
%tmp8 = phi %0* [ %tmp, %bb ], [ %tmp, %bb ]
|
|
|
|
unreachable
|
|
|
|
}
|
2012-06-26 03:47:37 +08:00
|
|
|
|
|
|
|
; When looking for the defining instruction for an objc_retainAutoreleasedReturnValue
|
|
|
|
; call, handle the case where it's an invoke in a different basic block.
|
|
|
|
; rdar://11714057
|
|
|
|
|
|
|
|
; CHECK: define void @_Z6doTestP8NSString() {
|
|
|
|
; CHECK: invoke.cont: ; preds = %entry
|
|
|
|
; CHECK-NEXT: call void asm sideeffect "mov\09r7, r7\09\09@ marker for objc_retainAutoreleaseReturnValue", ""()
|
2013-02-22 17:09:42 +08:00
|
|
|
; CHECK-NEXT: %tmp = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %call) [[NUW:#[0-9]+]]
|
2013-04-27 13:25:54 +08:00
|
|
|
; CHECK: }
|
2012-06-26 03:47:37 +08:00
|
|
|
define void @_Z6doTestP8NSString() {
|
|
|
|
entry:
|
|
|
|
%call = invoke i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* ()*)()
|
|
|
|
to label %invoke.cont unwind label %lpad
|
|
|
|
|
|
|
|
invoke.cont: ; preds = %entry
|
|
|
|
%tmp = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %call) nounwind
|
|
|
|
unreachable
|
|
|
|
|
|
|
|
lpad: ; preds = %entry
|
|
|
|
%tmp1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*)
|
|
|
|
cleanup
|
|
|
|
resume { i8*, i32 } undef
|
|
|
|
}
|
|
|
|
|
|
|
|
!clang.arc.retainAutoreleasedReturnValueMarker = !{!0}
|
|
|
|
|
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 = !{!"mov\09r7, r7\09\09@ marker for objc_retainAutoreleaseReturnValue"}
|
2013-02-22 17:09:42 +08:00
|
|
|
|
|
|
|
; CHECK: attributes #0 = { optsize }
|
|
|
|
; CHECK: attributes [[NUW]] = { nounwind }
|