xref: /aosp_15_r20/external/llvm/test/Transforms/MemCpyOpt/callslot_throw.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1; RUN: opt -S -memcpyopt < %s | FileCheck %s
2declare void @may_throw(i32* nocapture %x)
3
4; CHECK-LABEL: define void @test1(
5define void @test1(i32* nocapture noalias dereferenceable(4) %x) {
6entry:
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
18declare void @always_throws()
19
20; CHECK-LABEL: define void @test2(
21define void @test2(i32* nocapture noalias dereferenceable(4) %x) {
22entry:
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}
35