1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/test/Transforms/ObjCARC/contract-marker.ll
Akira Hatanaka 456368709d [ObjC][ARC] Fix a bug where the inline-asm retain/claim RV marker wasn't
inserted when the original call had a 'returned' argument

The code is testing whether the instruction BBI points to is the call
that is paired up with the retainRV/claimRV call, but it doesn't work
when the call has a 'returned' argument since GetArgRCIdentityRoot looks
through 'returned' arguments.

rdar://72485383
2020-12-18 16:59:06 -08:00

66 lines
2.1 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* @llvm.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* @llvm.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* @llvm.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* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %tcall) nounwind
tail call void @bar(i8* %0)
ret void
}
; CHECK-LABEL: define i8* @foo3(
; CHECK: call i8* @returnsArg(
; CHECK-NEXT: call void asm sideeffect
define i8* @foo3(i8* %a) {
%call = call i8* @returnsArg(i8* %a)
call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %call)
ret i8* %call
}
; CHECK-LABEL: define i8* @foo4(
; CHECK: call i8* @returnsArg(
; CHECK-NEXT: call void asm sideeffect
define i8* @foo4(i8* %a) {
%call = call i8* @returnsArg(i8* %a)
call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %a)
ret i8* %call
}
declare i32* @qux()
declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
declare i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8*)
declare void @bar(i8*)
declare i8* @returnsArg(i8* returned)
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"clang.arc.retainAutoreleasedReturnValueMarker", !"mov\09r7, r7\09\09@ marker for return value optimization"}
; CHECK: attributes [[NUW]] = { nounwind }