1 ; RUN: opt < %s -passes=simplifycfg -S | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
4 target triple = "wasm32-unknown-unknown"
6 ; This is a regression test for a bug in which we used phis() without
7 ; make_early_inc_range() in a for loop while deleting phi nodes.
9 define void @cleanup_phis() personality ptr @__gxx_wasm_personality_v0 {
12 to label %bb1 unwind label %ehcleanup
16 to label %invoke.cont unwind label %ehcleanup
18 invoke.cont: ; preds = %bb1
21 ehcleanup: ; preds = %bb1, %bb0
22 %phi0 = phi i32 [ 0, %bb0 ], [ 1, %bb1 ]
23 %phi1 = phi i32 [ 2, %bb0 ], [ 3, %bb1 ]
24 %0 = cleanuppad within none []
25 cleanupret from %0 unwind label %catchswitch
27 ; These two phi nodes were originally in ehcleanup. Both phi nodes should be
28 ; correctly copied to this catchswitch BB.
30 ; CHECK-NEXT: %phi0 = phi i32 [ 0, %bb0 ], [ 1, %bb1 ]
31 ; CHECK-NEXT: %phi1 = phi i32 [ 2, %bb0 ], [ 3, %bb1 ]
32 catchswitch: ; preds = %ehcleanup
33 %1 = catchswitch within none [label %catch] unwind to caller
35 catch: ; preds = %catchswitch
36 %2 = catchpad within %1 [ptr null]
37 call void @bar(i32 %phi0, i32 %phi1)
42 declare void @bar(i32, i32)
43 declare i32 @__gxx_wasm_personality_v0(...)