Upgrade syntax of tests using volatile instructions to use 'load volatile' instead...
[oota-llvm.git] / test / Transforms / ObjCARC / contract-storestrong.ll
1 ; RUN: opt -objc-arc-contract -S < %s | FileCheck %s
2
3 target datalayout = "e-p:64:64:64"
4
5 declare i8* @objc_retain(i8*)
6 declare void @objc_release(i8*)
7
8 @x = external global i8*
9
10 ; CHECK: define void @test0(
11 ; CHECK: entry:
12 ; CHECK-NEXT: call void @objc_storeStrong(i8** @x, i8* %p) nounwind
13 ; CHECK-NEXT: ret void
14 define void @test0(i8* %p) {
15 entry:
16   %0 = tail call i8* @objc_retain(i8* %p) nounwind
17   %tmp = load i8** @x, align 8
18   store i8* %0, i8** @x, align 8
19   tail call void @objc_release(i8* %tmp) nounwind
20   ret void
21 }
22
23 ; Don't do this if the load is volatile.
24
25 ;      CHECK: define void @test1(i8* %p) {
26 ; CHECK-NEXT: entry:
27 ; CHECK-NEXT:   %0 = tail call i8* @objc_retain(i8* %p) nounwind
28 ; CHECK-NEXT:   %tmp = load volatile i8** @x, align 8
29 ; CHECK-NEXT:   store i8* %0, i8** @x, align 8
30 ; CHECK-NEXT:   tail call void @objc_release(i8* %tmp) nounwind
31 ; CHECK-NEXT:   ret void
32 ; CHECK-NEXT: }
33 define void @test1(i8* %p) {
34 entry:
35   %0 = tail call i8* @objc_retain(i8* %p) nounwind
36   %tmp = load volatile i8** @x, align 8
37   store i8* %0, i8** @x, align 8
38   tail call void @objc_release(i8* %tmp) nounwind
39   ret void
40 }
41
42 ; Don't do this if the store is volatile.
43
44 ;      CHECK: define void @test2(i8* %p) {
45 ; CHECK-NEXT: entry:
46 ; CHECK-NEXT:   %0 = tail call i8* @objc_retain(i8* %p) nounwind
47 ; CHECK-NEXT:   %tmp = load i8** @x, align 8
48 ; CHECK-NEXT:   store volatile i8* %0, i8** @x, align 8
49 ; CHECK-NEXT:   tail call void @objc_release(i8* %tmp) nounwind
50 ; CHECK-NEXT:   ret void
51 ; CHECK-NEXT: }
52 define void @test2(i8* %p) {
53 entry:
54   %0 = tail call i8* @objc_retain(i8* %p) nounwind
55   %tmp = load i8** @x, align 8
56   store volatile i8* %0, i8** @x, align 8
57   tail call void @objc_release(i8* %tmp) nounwind
58   ret void
59 }