1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
llvm-mirror/test/Transforms/ObjCARC/contract-marker.ll
John McCall 02db7c55a3 Add support for objc_unsafeClaimAutoreleasedReturnValue to the
ObjC ARC Optimizer.

The main implication of this is:

1. Ensuring that we treat it conservatively in terms of optimization.
2. We put the ASM marker on it so that the runtime can recognize
objc_unsafeClaimAutoreleasedReturnValue from releaseRV.

<rdar://problem/21567064>

Patch by Michael Gottesman!

llvm-svn: 258970
2016-01-27 19:05:08 +00:00

46 lines
1.5 KiB
LLVM

; RUN: opt -S -objc-arc-contract < %s | FileCheck %s
; CHECK-LABEL: define void @foo() {
; CHECK: %call = tail call i32* @qux()
; CHECK-NEXT: %tcall = bitcast i32* %call to i8*
; CHECK-NEXT: call void asm sideeffect "mov\09r7, r7\09\09@ marker for return value optimization", ""()
; CHECK-NEXT: %0 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %tcall) [[NUW:#[0-9]+]]
; CHECK: }
define void @foo() {
entry:
%call = tail call i32* @qux()
%tcall = bitcast i32* %call to i8*
%0 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %tcall) nounwind
tail call void @bar(i8* %0)
ret void
}
; CHECK-LABEL: define void @foo2() {
; CHECK: %call = tail call i32* @qux()
; CHECK-NEXT: %tcall = bitcast i32* %call to i8*
; CHECK-NEXT: call void asm sideeffect "mov\09r7, r7\09\09@ marker for return value optimization", ""()
; CHECK-NEXT: %0 = tail call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %tcall) [[NUW:#[0-9]+]]
; CHECK: }
define void @foo2() {
entry:
%call = tail call i32* @qux()
%tcall = bitcast i32* %call to i8*
%0 = tail call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %tcall) nounwind
tail call void @bar(i8* %0)
ret void
}
declare i32* @qux()
declare i8* @objc_retainAutoreleasedReturnValue(i8*)
declare i8* @objc_unsafeClaimAutoreleasedReturnValue(i8*)
declare void @bar(i8*)
!clang.arc.retainAutoreleasedReturnValueMarker = !{!0}
!0 = !{!"mov\09r7, r7\09\09@ marker for return value optimization"}
; CHECK: attributes [[NUW]] = { nounwind }