From 2a049044bbd0ed76ccc88f6c9d34783158b444b3 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Tue, 8 Nov 2022 14:45:56 -0800 Subject: [PATCH] Add and use eachTerminalSuccessor() --- compiler/forget/src/HIR/EnterSSA.ts | 24 ++++-------- compiler/forget/src/HIR/HIRBuilder.ts | 32 ++-------------- .../forget/src/HIR/InferReferenceEffects.ts | 19 +++------- compiler/forget/src/HIR/visitors.ts | 37 +++++++++++++++++++ .../fixtures/hir/component.expect.md | 8 ++-- .../fixtures/hir/conditional-break.expect.md | 4 +- .../hir/conditional-on-mutable.expect.md | 8 ++-- ...reeze-possibly-mutable-arguments.expect.md | 4 +- .../hir/independent-across-if.expect.md | 2 +- .../hir/interdependent-across-if.expect.md | 2 +- .../fixtures/hir/logical-expression.expect.md | 12 +++--- .../hir/mutable-lifetime-loops.expect.md | 10 ++--- .../hir/mutable-liverange-loop.expect.md | 2 +- .../hir/reassignment-conditional.expect.md | 4 +- .../fixtures/hir/reverse-postorder.expect.md | 4 +- .../fixtures/hir/ssa-call-jsx-2.expect.md | 2 +- .../hir/ssa-complex-multiple-if.expect.md | 8 ++-- .../hir/ssa-complex-single-if.expect.md | 4 +- .../fixtures/hir/ssa-for-of.expect.md | 2 +- .../fixtures/hir/ssa-if-else.expect.md | 2 +- .../hir/ssa-objectexpression-phi.expect.md | 6 +-- .../fixtures/hir/ssa-return.expect.md | 4 +- .../fixtures/hir/ssa-simple-phi.expect.md | 4 +- .../fixtures/hir/ssa-single-if.expect.md | 2 +- .../fixtures/hir/ssa-throw.expect.md | 4 +- 25 files changed, 101 insertions(+), 109 deletions(-) diff --git a/compiler/forget/src/HIR/EnterSSA.ts b/compiler/forget/src/HIR/EnterSSA.ts index 9354a1c91b..e22d96606d 100644 --- a/compiler/forget/src/HIR/EnterSSA.ts +++ b/compiler/forget/src/HIR/EnterSSA.ts @@ -2,7 +2,6 @@ import { assertExhaustive } from "../Common/utils"; import { invariant } from "../CompilerError"; import { BasicBlock, - BlockId, HIRFunction, Identifier, Instruction, @@ -11,6 +10,7 @@ import { } from "./HIR"; import { Environment } from "./HIRBuilder"; import { printIdentifier } from "./PrintHIR"; +import { eachTerminalSuccessor } from "./visitors"; type IncompletePhi = { oldId: Identifier; @@ -186,7 +186,7 @@ export default function enterSSA(func: HIRFunction, env: Environment) { } for (const instr of block.instructions) { - rewriteUses(instr, builder); + rewriteInstructionUses(instr, builder); if (instr.lvalue != null) { const oldPlace = instr.lvalue.place; @@ -200,9 +200,9 @@ export default function enterSSA(func: HIRFunction, env: Environment) { } } - const outputs = rewriteUsesAndCollectOutputs(block, builder); - const outputBlocks = outputs.map((id) => func.body.blocks.get(id)!); - for (const output of outputBlocks) { + rewriteTerminalOperands(block, builder); + for (const outputId of eachTerminalSuccessor(block.terminal)) { + const output = func.body.blocks.get(outputId)!; let count; if (builder.unsealedPreds.has(output)) { count = builder.unsealedPreds.get(output)! - 1; @@ -218,11 +218,7 @@ export default function enterSSA(func: HIRFunction, env: Environment) { } } -function rewriteUsesAndCollectOutputs( - block: BasicBlock, - builder: SSABuilder -): Array { - const outputs: Array = []; +function rewriteTerminalOperands(block: BasicBlock, builder: SSABuilder): void { const { terminal } = block; switch (terminal.kind) { case "return": @@ -233,14 +229,11 @@ function rewriteUsesAndCollectOutputs( break; } case "goto": { - outputs.push(terminal.block); break; } case "if": { const { consequent, alternate } = terminal; terminal.test = builder.getPlace(terminal.test); - outputs.push(alternate); - outputs.push(consequent); break; } case "switch": { @@ -250,7 +243,6 @@ function rewriteUsesAndCollectOutputs( if (case_.test) { case_.test = builder.getPlace(case_.test); } - outputs.push(case_.block); } break; } @@ -261,11 +253,9 @@ function rewriteUsesAndCollectOutputs( ); } } - - return outputs; } -function rewriteUses(instr: Instruction, builder: SSABuilder) { +function rewriteInstructionUses(instr: Instruction, builder: SSABuilder) { const instrValue = instr.value; switch (instrValue.kind) { diff --git a/compiler/forget/src/HIR/HIRBuilder.ts b/compiler/forget/src/HIR/HIRBuilder.ts index 425279f9a6..140ee9eba1 100644 --- a/compiler/forget/src/HIR/HIRBuilder.ts +++ b/compiler/forget/src/HIR/HIRBuilder.ts @@ -19,7 +19,7 @@ import { Terminal, } from "./HIR"; import { printInstruction } from "./PrintHIR"; -import { mapTerminalSuccessors } from "./visitors"; +import { eachTerminalSuccessor, mapTerminalSuccessors } from "./visitors"; // ******************************************************************************************* // ******************************************************************************************* @@ -512,34 +512,8 @@ function markPredecessors(func: HIR) { const { terminal } = block; - switch (terminal.kind) { - case "return": - case "throw": { - break; - } - case "goto": { - visit(terminal.block, block); - break; - } - case "if": { - const { consequent, alternate } = terminal; - visit(alternate, block); - visit(consequent, block); - break; - } - case "switch": { - const { cases } = terminal; - for (const case_ of [...cases]) { - visit(case_.block, block); - } - break; - } - default: { - assertExhaustive( - terminal, - `Unexpected terminal kind '${(terminal as any).kind}'` - ); - } + for (const successor of eachTerminalSuccessor(terminal)) { + visit(successor, block); } } visit(func.entry, null); diff --git a/compiler/forget/src/HIR/InferReferenceEffects.ts b/compiler/forget/src/HIR/InferReferenceEffects.ts index 909a225ef7..353c01e561 100644 --- a/compiler/forget/src/HIR/InferReferenceEffects.ts +++ b/compiler/forget/src/HIR/InferReferenceEffects.ts @@ -16,15 +16,14 @@ import { InstructionValue, Phi, Place, - Terminal, ValueKind, } from "./HIR"; +import { printMixedHIR, printPlace, printSourceLocation } from "./PrintHIR"; import { eachInstructionOperand, eachTerminalOperand, - mapTerminalSuccessors, + eachTerminalSuccessor, } from "./visitors"; -import { printMixedHIR, printPlace, printSourceLocation } from "./PrintHIR"; /** * For every usage of a value in the given function, infers the effect or action @@ -137,17 +136,9 @@ export default function inferReferenceEffects(fn: HIRFunction) { const environment = incomingEnvironment.clone(); inferBlock(environment, block); - // TODO: add a `forEachTerminalSuccessor` helper, we don't actually want the result - // here - const _ = mapTerminalSuccessors( - block.terminal, - (nextBlockId, isFallthrough) => { - if (!isFallthrough) { - queue(nextBlockId, environment); - } - return nextBlockId; - } - ); + for (const nextBlockId of eachTerminalSuccessor(block.terminal)) { + queue(nextBlockId, environment); + } } } } diff --git a/compiler/forget/src/HIR/visitors.ts b/compiler/forget/src/HIR/visitors.ts index 67b8b0091a..c85c8529d7 100644 --- a/compiler/forget/src/HIR/visitors.ts +++ b/compiler/forget/src/HIR/visitors.ts @@ -129,6 +129,43 @@ export function mapTerminalSuccessors( } } +/** + * Iterates over the successor block ids of the provided terminal. The function is called + * specifically for the successors that define the standard control flow, and not + * pseduo-successors such as fallthroughs. + */ +export function* eachTerminalSuccessor(terminal: Terminal): Iterable { + switch (terminal.kind) { + case "goto": { + yield terminal.block; + break; + } + case "if": { + yield terminal.consequent; + yield terminal.alternate; + break; + } + case "switch": { + for (const case_ of terminal.cases) { + yield case_.block; + } + break; + } + case "return": { + break; + } + case "throw": { + break; + } + default: { + assertExhaustive( + terminal, + `Unexpected terminal kind '${(terminal as any as Terminal).kind}'` + ); + } + } +} + export function* eachTerminalOperand(terminal: Terminal): Iterable { switch (terminal.kind) { case "if": { diff --git a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md index dec530f244..f641ac34dd 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md @@ -43,7 +43,7 @@ bb0: [6] Const mutate max$32 = Call mutate Math$8.max(read $31, read maxItems$28) Goto bb1 bb1: - predecessor blocks: bb0 bb4 bb7 + predecessor blocks: bb0 bb7 bb4 If (read items$27) then:bb3 else:bb2 bb3: predecessor blocks: bb1 @@ -59,8 +59,8 @@ bb9: [10] Const mutate $39 = Call mutate seen$30.has(mutate item$10) Goto bb7 bb7: - predecessor blocks: bb9 bb8 - $40: phi(bb9: $39, bb8: $37) + predecessor blocks: bb8 bb9 + $40: phi(bb8: $37, bb9: $39) If (read $40) then:bb1 else:bb4 bb4: predecessor blocks: bb7 @@ -71,7 +71,7 @@ bb4: [15] Const mutate $49 = Binary read renderedItems$29.length >= read max$32 If (read $49) then:bb2 else:bb1 bb2: - predecessor blocks: bb1 bb4 + predecessor blocks: bb4 bb1 [16] Const mutate count$52 = read renderedItems$29.length [17] Const mutate $53 = "div" [18] Const mutate $54 = "\n " diff --git a/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md b/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md index a85337da08..3c62fd6bfa 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md @@ -118,7 +118,7 @@ bb2: [3] Call mutate a$4.push(read props$3.c) Goto bb1 bb1: - predecessor blocks: bb0 bb2 + predecessor blocks: bb2 bb0 [4] Call mutate a$4.push(read props$3.d) Return freeze a$4 ``` @@ -218,7 +218,7 @@ bb2: [3] Call mutate a$4.push(read props$3.c) Goto bb1 bb1: - predecessor blocks: bb2 bb0 + predecessor blocks: bb0 bb2 [4] Call mutate a$4.push(read props$3.d) Return freeze a$4 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md b/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md index 2486702d44..59ac6c8e60 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md @@ -75,14 +75,14 @@ bb2: [3] Call mutate a$7.push(read props$6.p0) Goto bb1 bb1: - predecessor blocks: bb0 bb2 + predecessor blocks: bb2 bb0 If (read props$6.p1) then:bb4 else:bb3 bb4: predecessor blocks: bb1 [4] Call mutate b$8.push(read props$6.p2) Goto bb3 bb3: - predecessor blocks: bb1 bb4 + predecessor blocks: bb4 bb1 [5] Const mutate $16 = JSX Return read $16 ``` @@ -120,14 +120,14 @@ bb2: [4] Call mutate a$9.push(read props$8.p0) Goto bb1 bb1: - predecessor blocks: bb0 bb2 + predecessor blocks: bb2 bb0 If (read props$8.p1) then:bb4 else:bb3 bb4: predecessor blocks: bb1 [5] Call mutate b$10.push(read props$8.p2) Goto bb3 bb3: - predecessor blocks: bb1 bb4 + predecessor blocks: bb4 bb1 [6] Const mutate $19 = JSX Return read $19 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md b/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md index 4572b6b99d..fef3216a20 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md @@ -39,8 +39,8 @@ bb3: [5] Reassign mutate a$12 = Array [] Goto bb1 bb1: - predecessor blocks: bb3 bb2 - a$14: phi(bb3: a$12, bb2: a$11) + predecessor blocks: bb2 bb3 + a$14: phi(bb2: a$11, bb3: a$12) [6] Call read useFreeze$5(freeze a$14) [7] Call read useFreeze$5(read a$14) [8] Call mutate call$6(read a$14) diff --git a/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md index f06f4eacbc..e0b43d1597 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md @@ -106,7 +106,7 @@ bb2: [4] Call mutate mutate$5(mutate b$10) Goto bb1 bb1: - predecessor blocks: bb0 bb2 + predecessor blocks: bb2 bb0 [5] Const mutate $14 = JSX Return read $14 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md index e5c457b009..9fbe734999 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md @@ -84,7 +84,7 @@ bb2: [3] Call mutate foo$5(mutate a$9, mutate b$10) Goto bb1 bb1: - predecessor blocks: bb0 bb2 + predecessor blocks: bb2 bb0 [4] Const mutate $14 = JSX Return read $14 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md b/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md index fd0ba8ce8a..99dc706b61 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md @@ -34,8 +34,8 @@ bb3: [3] Const mutate $7 = read $5 Goto bb1 bb1: - predecessor blocks: bb3 bb2 - $8: phi(bb3: $7, bb2: $6) + predecessor blocks: bb2 bb3 + $8: phi(bb2: $6, bb3: $7) Return freeze $8 ``` @@ -67,8 +67,8 @@ bb3: [3] Const mutate $7 = Call mutate g$4() Goto bb1 bb1: - predecessor blocks: bb3 bb2 - $8: phi(bb3: $7, bb2: $6) + predecessor blocks: bb2 bb3 + $8: phi(bb2: $6, bb3: $7) Return freeze $8 ``` @@ -102,8 +102,8 @@ bb3: [5] Const mutate $13 = Call mutate g$7() Goto bb1 bb1: - predecessor blocks: bb3 bb2 - $14: phi(bb3: $13, bb2: $12) + predecessor blocks: bb2 bb3 + $14: phi(bb2: $12, bb3: $13) Return freeze $14 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md b/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md index 097321fec6..954120c3ae 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md @@ -97,11 +97,11 @@ bb3: [12] Const mutate $29 = Call mutate cond$8(mutate a$21) If (read $29) then:bb2 else:bb1 bb2: - predecessor blocks: bb1 bb3 - a$30: phi(bb1: a$18, bb3: a$21) - b$31: phi(bb1: b$20, bb3: b$23) - c$32: phi(bb1: c$22, bb3: c$25) - d$33[-1:14]: phi(bb1: d$24, bb3: d$26) + predecessor blocks: bb3 bb1 + a$30: phi(bb3: a$21, bb1: a$18) + b$31: phi(bb3: b$23, bb1: b$20) + c$32: phi(bb3: c$25, bb1: c$22) + d$33[-1:14]: phi(bb3: d$26, bb1: d$24) If (read a$30) then:bb7 else:bb7 bb7: predecessor blocks: bb2 diff --git a/compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md b/compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md index 3525d20b4b..7c1f565124 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md @@ -83,7 +83,7 @@ bb3: [7] Const mutate $21 = Call mutate cond$7(mutate a$12) If (read $21) then:bb2 else:bb1 bb2: - predecessor blocks: bb1 bb3 + predecessor blocks: bb3 bb1 If (read a$12) then:bb7 else:bb7 bb7: predecessor blocks: bb2 diff --git a/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md index 35613a3c03..381a43c0f3 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md @@ -32,8 +32,8 @@ bb2: [4] Reassign mutate x$9 = Array [] Goto bb1 bb1: - predecessor blocks: bb0 bb2 - x$11: phi(bb0: x$7, bb2: x$9) + predecessor blocks: bb2 bb0 + x$11: phi(bb2: x$9, bb0: x$7) [5] Let mutate _$12 = JSX [6] Call read y$8.push(read props$6.p2) [7] Const mutate $15 = JSX diff --git a/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md index d086ca9225..0f68566208 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md @@ -72,8 +72,8 @@ bb13: [9] Reassign mutate x$15 = read props$6.c Goto bb1 bb1: - predecessor blocks: bb13 bb12 bb8 bb6 bb4 - x$16: phi(bb13: x$15, bb12: x$14, bb8: x$11, bb6: x$12, bb4: x$13) + predecessor blocks: bb8 bb6 bb4 bb12 bb13 + x$16: phi(bb8: x$11, bb6: x$12, bb4: x$13, bb12: x$14, bb13: x$15) [10] read x$16 Return ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md index ae6089d562..f436bd8709 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md @@ -48,7 +48,7 @@ bb2: [6] Let mutate _$15 = JSX Goto bb1 bb1: - predecessor blocks: bb0 bb2 + predecessor blocks: bb2 bb0 [7] Call mutate foo$4(read a$11, mutate b$12) [8] Const mutate $19 = "div" [9] Const mutate $20 = JSX diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md index 71d82b5c4d..549e167937 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md @@ -31,8 +31,8 @@ bb2: [5] Reassign mutate x$11 = 3 Goto bb1 bb1: - predecessor blocks: bb0 bb2 - x$17: phi(bb0: x$7, bb2: x$11) + predecessor blocks: bb2 bb0 + x$17: phi(bb2: x$11, bb0: x$7) [6] Const mutate $12 = 3 [7] Const mutate $14 = Binary read y$8 === read $12 If (read $14) then:bb4 else:bb3 @@ -41,8 +41,8 @@ bb4: [8] Reassign mutate x$15 = 5 Goto bb3 bb3: - predecessor blocks: bb1 bb4 - x$16: phi(bb1: x$17, bb4: x$15) + predecessor blocks: bb4 bb1 + x$16: phi(bb4: x$15, bb1: x$17) [9] Reassign mutate y$18 = read x$16 Return ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md index 68bce41d37..02c4ad3059 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md @@ -28,8 +28,8 @@ bb2: [5] Reassign mutate x$9 = 3 Goto bb1 bb1: - predecessor blocks: bb0 bb2 - x$10: phi(bb0: x$5, bb2: x$9) + predecessor blocks: bb2 bb0 + x$10: phi(bb2: x$9, bb0: x$5) [6] Reassign mutate y$11 = read x$10 Return ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md index 1a77838fda..d4b10a2296 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md @@ -22,7 +22,7 @@ bb0: [1] Let mutate items$5 = Array [] Goto bb1 bb1: - predecessor blocks: bb0 bb3 bb5 + predecessor blocks: bb0 bb5 bb3 If (read items$5) then:bb3 else:bb2 bb3: predecessor blocks: bb1 diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md index 0e1063759b..84479fb53c 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md @@ -31,7 +31,7 @@ bb3: [4] Let mutate z$8 = read x$5 Goto bb1 bb1: - predecessor blocks: bb3 bb2 + predecessor blocks: bb2 bb3 Return ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md index b9459ed34e..9960e3a350 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md @@ -36,9 +36,9 @@ bb3: [6] Reassign mutate y$11 = 3 Goto bb1 bb1: - predecessor blocks: bb3 bb2 - x$12: phi(bb3: x$6, bb2: x$10) - y$13: phi(bb3: y$11, bb2: y$7) + predecessor blocks: bb2 bb3 + x$12: phi(bb2: x$10, bb3: x$6) + y$13: phi(bb2: y$7, bb3: y$11) [7] Let mutate t$14 = Object { x: read x$12, y: read y$13 } Return freeze t$14 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md index 8c7c5be957..bdffb7a035 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md @@ -26,8 +26,8 @@ bb2: [4] Reassign mutate x$7 = 2 Goto bb1 bb1: - predecessor blocks: bb0 bb2 - x$8: phi(bb0: x$4, bb2: x$7) + predecessor blocks: bb2 bb0 + x$8: phi(bb2: x$7, bb0: x$4) Return read x$8 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md index 08c43662d3..2f0495755d 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md @@ -33,8 +33,8 @@ bb3: [5] Reassign mutate y$9 = 2 Goto bb1 bb1: - predecessor blocks: bb3 bb2 - y$10: phi(bb3: y$9, bb2: y$8) + predecessor blocks: bb2 bb3 + y$10: phi(bb2: y$8, bb3: y$9) [6] Let mutate x$11 = read y$10 Return ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md index bbd0b8499c..85664e30cf 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md @@ -25,7 +25,7 @@ bb2: [3] Let mutate z$6 = Binary read x$4 + read y$5 Goto bb1 bb1: - predecessor blocks: bb0 bb2 + predecessor blocks: bb2 bb0 Return ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md index 504f6a72e4..7a199a5958 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md @@ -25,8 +25,8 @@ bb2: [4] Reassign mutate x$7 = 2 Goto bb1 bb1: - predecessor blocks: bb0 bb2 - x$8: phi(bb0: x$4, bb2: x$7) + predecessor blocks: bb2 bb0 + x$8: phi(bb2: x$7, bb0: x$4) Throw read x$8 ```