1 ; RUN: opt -basicaa -objc-arc -S < %s | FileCheck %s
3 target datalayout = "e-p:64:64:64"
5 declare i8* @objc_retain(i8*)
6 declare i8* @objc_retainAutorelease(i8*)
7 declare void @objc_release(i8*)
8 declare i8* @objc_autorelease(i8*)
10 declare void @clang.arc.use(...)
12 declare void @test0_helper(i8*, i8**)
14 ; Ensure that we honor clang.arc.use as a use and don't miscompile
15 ; the reduced test case from <rdar://13195034>.
17 ; FIXME: the fact that we re-order retains w.r.t. @clang.arc.use could
18 ; be problematic if we get run twice, e.g. under LTO.
20 ; CHECK: define void @test0(
21 ; CHECK: @objc_retain(i8* %x)
22 ; CHECK-NEXT: store i8* %y, i8** %temp0
23 ; CHECK-NEXT: @objc_retain(i8* %y)
24 ; CHECK-NEXT: call void @test0_helper
25 ; CHECK-NEXT: [[VAL1:%.*]] = load i8** %temp0
26 ; CHECK-NEXT: call void (...)* @clang.arc.use(i8* %y)
27 ; CHECK-NEXT: @objc_retain(i8* [[VAL1]])
28 ; CHECK-NEXT: @objc_release(i8* %y)
29 ; CHECK-NEXT: store i8* [[VAL1]], i8** %temp1
30 ; CHECK-NEXT: call void @test0_helper
31 ; CHECK-NEXT: [[VAL2:%.*]] = load i8** %temp1
32 ; CHECK-NEXT: call void (...)* @clang.arc.use(i8* [[VAL1]])
33 ; CHECK-NEXT: @objc_retain(i8* [[VAL2]])
34 ; CHECK-NEXT: @objc_release(i8* [[VAL1]])
35 ; CHECK-NEXT: @objc_autorelease(i8* %x)
36 ; CHECK-NEXT: store i8* %x, i8** %out
37 ; CHECK-NEXT: @objc_release(i8* [[VAL2]])
38 ; CHECK-NEXT: ret void
39 define void @test0(i8** %out, i8* %x, i8* %y) {
41 %temp0 = alloca i8*, align 8
42 %temp1 = alloca i8*, align 8
43 %0 = call i8* @objc_retain(i8* %x) nounwind
44 %1 = call i8* @objc_retain(i8* %y) nounwind
45 store i8* %y, i8** %temp0
46 call void @test0_helper(i8* %x, i8** %temp0)
47 %val1 = load i8** %temp0
48 %2 = call i8* @objc_retain(i8* %val1) nounwind
49 call void (...)* @clang.arc.use(i8* %y) nounwind
50 call void @objc_release(i8* %y) nounwind
51 store i8* %val1, i8** %temp1
52 call void @test0_helper(i8* %x, i8** %temp1)
53 %val2 = load i8** %temp1
54 %3 = call i8* @objc_retain(i8* %val2) nounwind
55 call void (...)* @clang.arc.use(i8* %val1) nounwind
56 call void @objc_release(i8* %val1) nounwind
57 %4 = call i8* @objc_retain(i8* %x) nounwind
58 %5 = call i8* @objc_autorelease(i8* %x) nounwind
59 store i8* %x, i8** %out
60 call void @objc_release(i8* %val2) nounwind
61 call void @objc_release(i8* %x) nounwind