John McCall | d935e9c | 2011-06-15 23:37:01 +0000 | [diff] [blame] | 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: |
Dan Gohman | 8ee108b | 2012-01-19 19:14:36 +0000 | [diff] [blame] | 12 | ; CHECK-NEXT: tail call void @objc_storeStrong(i8** @x, i8* %p) nounwind |
John McCall | d935e9c | 2011-06-15 23:37:01 +0000 | [diff] [blame] | 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 |
Eli Friedman | 02e737b | 2011-08-12 22:50:01 +0000 | [diff] [blame] | 28 | ; CHECK-NEXT: %tmp = load volatile i8** @x, align 8 |
John McCall | d935e9c | 2011-06-15 23:37:01 +0000 | [diff] [blame] | 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 |
Chris Lattner | 6a144a2 | 2011-11-27 06:54:59 +0000 | [diff] [blame] | 36 | %tmp = load volatile i8** @x, align 8 |
John McCall | d935e9c | 2011-06-15 23:37:01 +0000 | [diff] [blame] | 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 |
Eli Friedman | 02e737b | 2011-08-12 22:50:01 +0000 | [diff] [blame] | 48 | ; CHECK-NEXT: store volatile i8* %0, i8** @x, align 8 |
John McCall | d935e9c | 2011-06-15 23:37:01 +0000 | [diff] [blame] | 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 |
Chris Lattner | 6a144a2 | 2011-11-27 06:54:59 +0000 | [diff] [blame] | 56 | store volatile i8* %0, i8** @x, align 8 |
John McCall | d935e9c | 2011-06-15 23:37:01 +0000 | [diff] [blame] | 57 | tail call void @objc_release(i8* %tmp) nounwind |
| 58 | ret void |
| 59 | } |