Files
sdk/pkg/cfg/testcases/loops.dart.expect
Alexander Markov da1f06f239 [vm,compiler] Fix loop computation in case of try blocks
If catch block is included into the loop, we should also include
the whole try body as there are implicit control flow edges between
each block in a try body and corresponding catch block.

If try body is not included, analysis of loop invariant loads
could miss conflicting stores and may conclude that certain loads are
loop invariant although they are not.

TEST=runtime/tests/vm/dart/regress_63336_test.dart
Fixes https://github.com/dart-lang/sdk/issues/63336

Change-Id: I9d6b73e24554ee3bfbcc722fa59634ea90b00abb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501560
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-05-08 06:37:30 -07:00

164 lines
4.7 KiB
Plaintext

--- nested
B0 = EntryBlock() dominates:(B4)
v2 = Constant(0)
v7 = Constant(10)
v15 = Constant(5)
v21 = Constant(1)
v43 = Constant(3)
v59 = Constant(null)
v1 = Parameter(i)
Goto(B4)
B4 = JoinBlock(B0, B18) idom:B0 dominates:(B10, B9) loop-header (depth:1 body:(B4, B9, B12, B18, B17) back-edges:(B18))
v64 = Phi(v2, v27)
v8 = Comparison int <(v64, v7)
Branch(v8, true: B9, false: B10)
B9 = TargetBlock() idom:B4 dominates:(B12) in-loop:B4
Goto(B12)
B12 = JoinBlock(B9, B17) idom:B9 dominates:(B18, B17) loop-header (depth:2 body:(B12, B17) back-edges:(B17))
v63 = Phi(v64, v22)
v16 = Comparison int <(v63, v15)
Branch(v16, true: B17, false: B18)
B17 = TargetBlock() idom:B12 in-loop:B12
v22 = BinaryIntOp +(v63, v21)
DirectCall print(v22)
Goto(B12)
B18 = TargetBlock() idom:B12 in-loop:B4
v27 = BinaryIntOp +(v63, v21)
Goto(B4)
B10 = TargetBlock() idom:B4 dominates:(B32)
DirectCall print(v1)
Goto(B32)
B32 = JoinBlock(B10, B46) idom:B10 dominates:(B37, B36) loop-header (depth:1 body:(B32, B36, B40, B46, B45) back-edges:(B46))
v62 = Phi(v1, v61)
v35 = Comparison int <(v62, v7)
Branch(v35, true: B36, false: B37)
B36 = TargetBlock() idom:B32 dominates:(B40) in-loop:B32
Goto(B40)
B40 = JoinBlock(B36, B45) idom:B36 dominates:(B46, B45) loop-header (depth:2 body:(B40, B45) back-edges:(B45))
v65 = Phi(v2, v53)
v61 = Phi(v62, v50)
v44 = Comparison int <(v65, v43)
Branch(v44, true: B45, false: B46)
B45 = TargetBlock() idom:B40 in-loop:B40
v50 = BinaryIntOp +(v61, v65)
v53 = BinaryIntOp +(v65, v21)
Goto(B40)
B46 = TargetBlock() idom:B40 in-loop:B32
Goto(B32)
B37 = TargetBlock() idom:B32
DirectCall print(v62)
Return(v59)
--- chainedHeaders
B0 = EntryBlock() dominates:(B2)
Constant(17)
v11 = Constant(0)
v18 = Constant(2)
v25 = Constant(null)
v29 = Constant(-17)
v1 = Parameter(i)
Goto(B2)
B2 = JoinBlock(B0, B21) idom:B0 dominates:(B4) loop-header (depth:1 body:(B2, B4, B14, B21, B13) back-edges:(B21))
v27 = Phi(v1, v30)
Goto(B4)
B4 = JoinBlock(B2, B13) idom:B2 dominates:(B14, B13) loop-header (depth:2 body:(B4, B13) back-edges:(B13))
v28 = Phi(v27, v30)
v30 = BinaryIntOp +(v28, v29)
v12 = Comparison int >=(v30, v11)
Branch(v12, true: B13, false: B14)
B13 = TargetBlock() idom:B4 in-loop:B4
Goto(B4)
B14 = TargetBlock() idom:B4 dominates:(B22, B21) in-loop:B2
v19 = BinaryIntOp %(v30, v18)
v20 = Comparison int ==(v19, v11)
Branch(v20, true: B21, false: B22)
B21 = TargetBlock() idom:B14 in-loop:B2
Goto(B2)
B22 = TargetBlock() idom:B14
Return(v25)
--- irreducible
B0 = EntryBlock() dominates:(B8, B34, B4, B3, B7)
v5 = Constant(1)
v11 = Constant(2)
v27 = Constant(10)
v38 = Constant(null)
v1 = Parameter(i)
v6 = Comparison int ==(v1, v5)
Branch(v6, true: B7, false: B8)
B7 = TargetBlock() idom:B0
Goto(B3)
B8 = TargetBlock() idom:B0 dominates:(B14, B13)
v12 = Comparison int ==(v1, v11)
Branch(v12, true: B13, false: B14)
B13 = TargetBlock() idom:B8
Goto(B4)
B4 = JoinBlock(B13, B3) idom:B0 dominates:(B30, B29)
v40 = Phi(v1, v20)
v24 = BinaryIntOp +(v40, v11)
v28 = Comparison int >(v24, v27)
Branch(v28, true: B29, false: B30)
B29 = TargetBlock() idom:B4
Goto(B34)
B30 = TargetBlock() idom:B4
Goto(B3)
B3 = JoinBlock(B30, B7) idom:B0
v41 = Phi(v24, v1)
v20 = BinaryIntOp +(v41, v5)
Goto(B4)
B14 = TargetBlock() idom:B8
Goto(B34)
B34 = JoinBlock(B14, B29) idom:B0
Return(v38)
--- withTryBlock
B0 = EntryBlock() dominates:(B3)
v1 = Constant(43)
v6 = Constant(1)
v9 = Constant(0)
v20 = Constant("bye")
v22 = Constant(null)
v42 = Constant(-1)
Goto(B3)
B3 = JoinBlock(B0, B28) idom:B0 dominates:(B12, B11) loop-header (depth:1 body:(B3, B11, B15, B28, B14) back-edges:(B28))
v41 = Phi(v1, v43)
v43 = BinaryIntOp +(v41, v42)
v10 = Comparison int >(v43, v9)
Branch(v10, true: B11, false: B12)
B11 = TargetBlock() idom:B3 dominates:(B15, B14) in-loop:B3
TryEntry(try-body: B14, catch-block: B15)
B14 = TargetBlock() exception-handler:B15 idom:B11 in-loop:B3
v17 = LoadStaticField(var63)
v18 = BinaryIntOp +(v17, v6)
StoreStaticField(var63, v18)
Throw(v20)
B15 = CatchBlock() idom:B11 dominates:(B28, B27) in-loop:B3
v23 = Parameter(#exception)
v24 = Parameter(#stackTrace)
v26 = TypeTest(v23, StackOverflowError)
Branch(v26, true: B27, false: B28)
B27 = TargetBlock() idom:B15
Throw(v23, v24)
B28 = TargetBlock() idom:B15 in-loop:B3
v35 = LoadStaticField(var63)
StoreStaticField(var68, v35)
Goto(B3)
B12 = TargetBlock() idom:B3
Return(v22)
--- main
B0 = EntryBlock()
v1 = Constant(null)
Return(v1)
--- field-init var63
B0 = EntryBlock()
v1 = Constant(28)
Return(v1)
--- field-init var68
B0 = EntryBlock()
v1 = Constant(44)
Return(v1)