1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes='sroa<preserve-cfg>' -S | FileCheck %s --check-prefixes=CHECK,CHECK-PRESERVE-CFG
3 ; RUN: opt < %s -passes='sroa<modify-cfg>' -S | FileCheck %s --check-prefixes=CHECK,CHECK-MODIFY-CFG
5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
8 %struct.foo = type { i32 }
9 declare i32 @__gxx_wasm_personality_v0(...)
12 ; Tests if the SROA pass correctly bails out on rewriting PHIs in a catchswitch
14 define void @test_phi_catchswitch() personality ptr @__gxx_wasm_personality_v0 {
15 ; CHECK-LABEL: @test_phi_catchswitch(
17 ; CHECK-NEXT: [[TMP:%.*]] = alloca [[STRUCT_FOO:%.*]], align 4
18 ; CHECK-NEXT: invoke void @foo()
19 ; CHECK-NEXT: to label [[BB3:%.*]] unwind label [[BB10:%.*]]
21 ; CHECK-NEXT: invoke void @foo()
22 ; CHECK-NEXT: to label [[BB9:%.*]] unwind label [[CATCH_DISPATCH:%.*]]
23 ; CHECK: catch.dispatch:
24 ; CHECK-NEXT: [[TMP5:%.*]] = phi ptr [ [[TMP]], [[BB3]] ]
25 ; CHECK-NEXT: [[TMP6:%.*]] = catchswitch within none [label %catch.start] unwind label [[BB10]]
27 ; CHECK-NEXT: [[TMP8:%.*]] = catchpad within [[TMP6]] [ptr null]
28 ; CHECK-NEXT: unreachable
30 ; CHECK-NEXT: unreachable
32 ; CHECK-NEXT: [[TMP11:%.*]] = phi ptr [ [[TMP]], [[ENTRY:%.*]] ], [ [[TMP5]], [[CATCH_DISPATCH]] ]
33 ; CHECK-NEXT: [[TMP12:%.*]] = cleanuppad within none []
34 ; CHECK-NEXT: store i32 0, ptr [[TMP11]], align 4
35 ; CHECK-NEXT: unreachable
38 %tmp = alloca %struct.foo, align 4
40 to label %bb3 unwind label %bb10
44 to label %bb9 unwind label %catch.dispatch
46 catch.dispatch: ; preds = %bb3
47 ; While rewriting the alloca in the entry BB, the SROA pass tries to insert a
48 ; non-PHI instruction in this BB by calling getFirstInsertionPt(), which is
49 ; not possible in a catchswitch BB. This test checks if we correctly bail out
51 %tmp5 = phi ptr [ %tmp, %bb3 ]
52 %tmp6 = catchswitch within none [label %catch.start] unwind label %bb10
54 catch.start: ; preds = %catch.dispatch
55 %tmp8 = catchpad within %tmp6 [ptr null]
61 bb10: ; preds = %catch.dispatch, %entry
62 %tmp11 = phi ptr [ %tmp, %entry ], [ %tmp5, %catch.dispatch ]
63 %tmp12 = cleanuppad within none []
64 store i32 0, ptr %tmp11, align 4
67 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
68 ; CHECK-MODIFY-CFG: {{.*}}
69 ; CHECK-PRESERVE-CFG: {{.*}}