diff --git a/test/compiler/ssair.jl b/test/compiler/ssair.jl index 88ce5985a23ac1..e11cc030f4f1ac 100644 --- a/test/compiler/ssair.jl +++ b/test/compiler/ssair.jl @@ -96,3 +96,19 @@ let Meta.isexpr(ex, :meta) end end + +# PR #32145 +# Make sure IncrementalCompact can handle blocks with predecessors of index 0 +# while removing blocks with no predecessors. +let cfg = CFG(BasicBlock[ + make_bb([] , [2, 4]), + make_bb([1] , [4, 5]), + make_bb([] , [4] ), # should be removed + make_bb([0, 1, 2] , [5] ), # 0 predecessor should be preserved + make_bb([2, 3] , [] ), +], Int[]) + code = Compiler.IRCode( + [], [], Int32[], UInt8[], cfg, LineInfoNode[], [], [], []) + compact = Compiler.IncrementalCompact(code, true) + @test length(compact.result_bbs) == 4 && 0 in compact.result_bbs[3].preds +end