David Majnemer | d99068d | 2016-05-26 19:24:24 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -memcpyopt < %s | FileCheck %s |
| 2 | declare void @may_throw(i32* nocapture %x) |
| 3 | |
| 4 | ; CHECK-LABEL: define void @test1( |
| 5 | define void @test1(i32* nocapture noalias dereferenceable(4) %x) { |
| 6 | entry: |
| 7 | %t = alloca i32, align 4 |
| 8 | call void @may_throw(i32* nonnull %t) |
| 9 | %load = load i32, i32* %t, align 4 |
| 10 | store i32 %load, i32* %x, align 4 |
| 11 | ; CHECK: %[[t:.*]] = alloca i32, align 4 |
| 12 | ; CHECK-NEXT: call void @may_throw(i32* {{.*}} %[[t]]) |
| 13 | ; CHECK-NEXT: %[[load:.*]] = load i32, i32* %[[t]], align 4 |
| 14 | ; CHECK-NEXT: store i32 %[[load]], i32* %x, align 4 |
| 15 | ret void |
| 16 | } |
| 17 | |
| 18 | declare void @always_throws() |
| 19 | |
| 20 | ; CHECK-LABEL: define void @test2( |
| 21 | define void @test2(i32* nocapture noalias dereferenceable(4) %x) { |
| 22 | entry: |
| 23 | %t = alloca i32, align 4 |
| 24 | call void @may_throw(i32* nonnull %t) nounwind |
| 25 | %load = load i32, i32* %t, align 4 |
| 26 | call void @always_throws() |
| 27 | store i32 %load, i32* %x, align 4 |
| 28 | ; CHECK: %[[t:.*]] = alloca i32, align 4 |
| 29 | ; CHECK-NEXT: call void @may_throw(i32* {{.*}} %[[t]]) |
| 30 | ; CHECK-NEXT: %[[load:.*]] = load i32, i32* %[[t]], align 4 |
| 31 | ; CHECK-NEXT: call void @always_throws() |
| 32 | ; CHECK-NEXT: store i32 %[[load]], i32* %x, align 4 |
| 33 | ret void |
| 34 | } |