1 ; RUN: opt -objc-arc-contract -S < %s | FileCheck %s
3 target datalayout = "e-p:64:64:64"
5 declare i8* @objc_retain(i8*)
6 declare void @objc_release(i8*)
8 @x = external global i8*
10 ; CHECK: define void @test0(
12 ; CHECK-NEXT: call void @objc_storeStrong(i8** @x, i8* %p) nounwind
13 ; CHECK-NEXT: ret void
14 define void @test0(i8* %p) {
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
23 ; Don't do this if the load is volatile.
25 ; CHECK: define void @test1(i8* %p) {
27 ; CHECK-NEXT: %0 = tail call i8* @objc_retain(i8* %p) nounwind
28 ; CHECK-NEXT: %tmp = volatile load 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
33 define void @test1(i8* %p) {
35 %0 = tail call i8* @objc_retain(i8* %p) nounwind
36 %tmp = volatile load i8** @x, align 8
37 store i8* %0, i8** @x, align 8
38 tail call void @objc_release(i8* %tmp) nounwind
42 ; Don't do this if the store is volatile.
44 ; CHECK: define void @test2(i8* %p) {
46 ; CHECK-NEXT: %0 = tail call i8* @objc_retain(i8* %p) nounwind
47 ; CHECK-NEXT: %tmp = load i8** @x, align 8
48 ; CHECK-NEXT: volatile store i8* %0, i8** @x, align 8
49 ; CHECK-NEXT: tail call void @objc_release(i8* %tmp) nounwind
50 ; CHECK-NEXT: ret void
52 define void @test2(i8* %p) {
54 %0 = tail call i8* @objc_retain(i8* %p) nounwind
55 %tmp = load i8** @x, align 8
56 volatile store i8* %0, i8** @x, align 8
57 tail call void @objc_release(i8* %tmp) nounwind