1; RUN: opt < %s -sroa -S | FileCheck %s 2 3target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 4target triple = "wasm32-unknown-unknown" 5 6%struct.foo = type { i32 } 7declare i32 @__gxx_wasm_personality_v0(...) 8declare void @foo() 9 10; Tests if the SROA pass correctly bails out on rewriting PHIs in a catchswitch 11; BB. 12; CHECK-LABEL: @test_phi_catchswitch 13define void @test_phi_catchswitch() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) { 14entry: 15 ; CHECK: alloca 16 %tmp = alloca %struct.foo, align 4 17 %tmp2 = getelementptr inbounds %struct.foo, %struct.foo* %tmp, i32 0, i32 0 18 invoke void @foo() 19 to label %bb3 unwind label %bb10 20 21bb3: ; preds = %entry 22 invoke void @foo() 23 to label %bb9 unwind label %catch.dispatch 24 25catch.dispatch: ; preds = %bb3 26 ; While rewriting the alloca in the entry BB, the SROA pass tries to insert a 27 ; non-PHI instruction in this BB by calling getFirstInsertionPt(), which is 28 ; not possible in a catchswitch BB. This test checks if we correctly bail out 29 ; on these cases. 30 %tmp5 = phi i32* [ %tmp2, %bb3 ] 31 %tmp6 = catchswitch within none [label %catch.start] unwind label %bb10 32 33catch.start: ; preds = %catch.dispatch 34 %tmp8 = catchpad within %tmp6 [i8* null] 35 unreachable 36 37bb9: ; preds = %bb3 38 unreachable 39 40bb10: ; preds = %catch.dispatch, %entry 41 %tmp11 = phi i32* [ %tmp2, %entry ], [ %tmp5, %catch.dispatch ] 42 %tmp12 = cleanuppad within none [] 43 store i32 0, i32* %tmp11, align 4 44 unreachable 45} 46