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 4 5target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 6target triple = "wasm32-unknown-unknown" 7 8%struct.foo = type { i32 } 9declare i32 @__gxx_wasm_personality_v0(...) 10declare void @foo() 11 12; Tests if the SROA pass correctly bails out on rewriting PHIs in a catchswitch 13; BB. 14define void @test_phi_catchswitch() personality ptr @__gxx_wasm_personality_v0 { 15; CHECK-LABEL: @test_phi_catchswitch( 16; CHECK-NEXT: entry: 17; CHECK-NEXT: [[TMP:%.*]] = alloca [[STRUCT_FOO:%.*]], align 4 18; CHECK-NEXT: invoke void @foo() 19; CHECK-NEXT: to label [[BB3:%.*]] unwind label [[BB10:%.*]] 20; CHECK: bb3: 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]] 26; CHECK: catch.start: 27; CHECK-NEXT: [[TMP8:%.*]] = catchpad within [[TMP6]] [ptr null] 28; CHECK-NEXT: unreachable 29; CHECK: bb9: 30; CHECK-NEXT: unreachable 31; CHECK: bb10: 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 36; 37entry: 38 %tmp = alloca %struct.foo, align 4 39 invoke void @foo() 40 to label %bb3 unwind label %bb10 41 42bb3: ; preds = %entry 43 invoke void @foo() 44 to label %bb9 unwind label %catch.dispatch 45 46catch.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 50 ; on these cases. 51 %tmp5 = phi ptr [ %tmp, %bb3 ] 52 %tmp6 = catchswitch within none [label %catch.start] unwind label %bb10 53 54catch.start: ; preds = %catch.dispatch 55 %tmp8 = catchpad within %tmp6 [ptr null] 56 unreachable 57 58bb9: ; preds = %bb3 59 unreachable 60 61bb10: ; 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 65 unreachable 66} 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: {{.*}} 70