From e69888054c7afcc9d37e52ac47b7bd606dc4a49b Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Fri, 4 Nov 2022 16:39:44 +0000 Subject: [PATCH] [hir] Add id to number Instruction --- compiler/forget/src/HIR/BuildHIR.ts | 12 +++++ compiler/forget/src/HIR/HIR.ts | 1 + compiler/forget/src/HIR/HIRBuilder.ts | 12 +++++ compiler/forget/src/HIR/PrintHIR.ts | 7 +-- .../src/__tests__/fixtures/hir/call.expect.md | 16 +++---- .../fixtures/hir/component.expect.md | 48 +++++++++---------- .../fixtures/hir/conditional-break.expect.md | 42 ++++++++-------- .../hir/conditional-on-mutable.expect.md | 22 ++++----- .../fixtures/hir/constructor.expect.md | 16 +++---- .../fixtures/hir/frozen-after-alias.expect.md | 8 ++-- .../fixtures/hir/hook-call.expect.md | 14 +++--- .../hir/hooks-freeze-arguments.expect.md | 8 ++-- ...reeze-possibly-mutable-arguments.expect.md | 16 +++---- .../hir/independent-across-if.expect.md | 10 ++-- .../fixtures/hir/independent.expect.md | 6 +-- .../hir/interdependent-across-if.expect.md | 8 ++-- .../fixtures/hir/interdependent.expect.md | 8 ++-- .../fixtures/hir/logical-expression.expect.md | 22 ++++----- .../hir/mutable-lifetime-loops.expect.md | 28 +++++------ .../mutable-lifetime-with-aliasing.expect.md | 18 +++---- .../hir/property-assignment.expect.md | 12 ++--- .../hir/reassignment-conditional.expect.md | 14 +++--- .../fixtures/hir/reassignment.expect.md | 14 +++--- .../fixtures/hir/reverse-postorder.expect.md | 20 ++++---- .../__tests__/fixtures/hir/simple.expect.md | 10 ++-- .../hir/ssa-arrayexpression.expect.md | 6 +-- .../fixtures/hir/ssa-call-jsx.expect.md | 16 +++---- .../hir/ssa-complex-multiple-if.expect.md | 18 +++---- .../hir/ssa-complex-single-if.expect.md | 12 ++--- .../fixtures/hir/ssa-for-of.expect.md | 6 +-- .../__tests__/fixtures/hir/ssa-for.expect.md | 10 ++-- .../fixtures/hir/ssa-if-else.expect.md | 8 ++-- .../fixtures/hir/ssa-newexpression.expect.md | 6 +-- .../hir/ssa-objectexpression-phi.expect.md | 14 +++--- .../hir/ssa-objectexpression.expect.md | 6 +-- .../fixtures/hir/ssa-property-call.expect.md | 8 ++-- .../fixtures/hir/ssa-property.expect.md | 6 +-- .../fixtures/hir/ssa-return.expect.md | 8 ++-- .../fixtures/hir/ssa-simple-phi.expect.md | 12 ++--- .../fixtures/hir/ssa-simple.expect.md | 4 +- .../fixtures/hir/ssa-single-if.expect.md | 6 +-- .../fixtures/hir/ssa-switch.expect.md | 24 +++++----- .../fixtures/hir/ssa-throw.expect.md | 8 ++-- .../fixtures/hir/ssa-while.expect.md | 10 ++-- .../hir/switch-non-final-default.expect.md | 22 ++++----- .../__tests__/fixtures/hir/switch.expect.md | 22 ++++----- 46 files changed, 325 insertions(+), 299 deletions(-) diff --git a/compiler/forget/src/HIR/BuildHIR.ts b/compiler/forget/src/HIR/BuildHIR.ts index 71d6fa9bd9..ef46205ce7 100644 --- a/compiler/forget/src/HIR/BuildHIR.ts +++ b/compiler/forget/src/HIR/BuildHIR.ts @@ -582,6 +582,7 @@ function lowerStatement( }; } builder.push({ + id: 0, lvalue: { place: id, kind }, value, loc: declaration.node.loc ?? GeneratedSource, @@ -598,6 +599,7 @@ function lowerStatement( return; } builder.push({ + id: 0, lvalue: null, value, loc: stmt.node.loc ?? GeneratedSource, @@ -636,6 +638,7 @@ function lowerStatement( case "TSTypeAliasDeclaration": case "WithStatement": { builder.push({ + id: 0, lvalue: null, loc: stmtPath.node.loc ?? GeneratedSource, value: { @@ -835,6 +838,7 @@ function lowerExpression( loc: left.loc, }; builder.push({ + id: 0, value: { kind: "Primitive", value: null, @@ -852,6 +856,7 @@ function lowerExpression( loc: left.loc, }; builder.push({ + id: 0, lvalue: { place: { ...condPlace }, kind: InstructionKind.Const, @@ -888,6 +893,7 @@ function lowerExpression( const operator = expr.node.operator; todoInvariant(operator === "=", "todo: support non-simple assignment"); builder.push({ + id: 0, lvalue: { place: left, kind: InstructionKind.Reassign }, value: right, loc: exprLoc, @@ -981,6 +987,7 @@ function lowerConditional( const consequentBlock = builder.enter((blockId) => { let value = consequent(); builder.push({ + id: 0, value, lvalue: { place: { ...place }, kind: InstructionKind.Const }, loc: value.loc, @@ -994,6 +1001,7 @@ function lowerConditional( const alternateBlock = builder.enter((blockId) => { let value = alternate(); builder.push({ + id: 0, value, lvalue: { place: { ...place }, kind: InstructionKind.Const }, loc: value.loc, @@ -1049,6 +1057,7 @@ function lowerJsxElementName( loc: exprLoc, }; builder.push({ + id: 0, value: { kind: "Primitive", value: tag, @@ -1088,6 +1097,7 @@ function lowerJsxElement( loc: exprLoc, }; builder.push({ + id: 0, value: { kind: "JSXText", value: exprPath.node.value, @@ -1110,6 +1120,7 @@ function lowerJsxElement( loc: exprLoc, }; builder.push({ + id: 0, value: { kind: "OtherStatement", node: exprNode, @@ -1139,6 +1150,7 @@ function lowerExpressionToPlace( loc: exprLoc, }; builder.push({ + id: 0, value: instr, loc: exprLoc, lvalue: { place: { ...place }, kind: InstructionKind.Const }, diff --git a/compiler/forget/src/HIR/HIR.ts b/compiler/forget/src/HIR/HIR.ts index 4ff5422e32..9d993b5d5f 100644 --- a/compiler/forget/src/HIR/HIR.ts +++ b/compiler/forget/src/HIR/HIR.ts @@ -149,6 +149,7 @@ export type SwitchTerminal = { * or may occur only for side-effects (many expression statements). */ export type Instruction = { + id: number; lvalue: LValue | null; value: InstructionValue; loc: SourceLocation; diff --git a/compiler/forget/src/HIR/HIRBuilder.ts b/compiler/forget/src/HIR/HIRBuilder.ts index bb198b5620..6a013ce2ad 100644 --- a/compiler/forget/src/HIR/HIRBuilder.ts +++ b/compiler/forget/src/HIR/HIRBuilder.ts @@ -18,6 +18,7 @@ import { makeBlockId, Terminal, } from "./HIR"; +import { printInstruction } from "./PrintHIR"; // ******************************************************************************************* // ******************************************************************************************* @@ -147,6 +148,7 @@ export default class HIRBuilder { }); // then convert to reverse postorder const blocks = reversePostorderBlocks(reduced); + markInstructionIds(blocks); markPredecessors(blocks); return blocks; } @@ -483,6 +485,16 @@ function reversePostorderBlocks(func: HIR): HIR { }; } +function markInstructionIds(func: HIR) { + let id = 0; + for (const [_, block] of func.blocks) { + for (const instr of block.instructions) { + invariant(instr.id === 0, `${printInstruction(instr)} already visited!`); + instr.id = ++id; + } + } +} + function markPredecessors(func: HIR) { const visited: Set = new Set(); function visit(blockId: BlockId, prevBlock?: BasicBlock) { diff --git a/compiler/forget/src/HIR/PrintHIR.ts b/compiler/forget/src/HIR/PrintHIR.ts index 27e5b9a7fa..21b3c60e5f 100644 --- a/compiler/forget/src/HIR/PrintHIR.ts +++ b/compiler/forget/src/HIR/PrintHIR.ts @@ -82,13 +82,14 @@ export function printMixedHIR( } } -function printInstruction(instr: Instruction): string { +export function printInstruction(instr: Instruction): string { + const id = `[${instr.id}]`; const value = printInstructionValue(instr.value); if (instr.lvalue !== null) { - return `${printLValue(instr.lvalue)} = ${value}`; + return `${id} ${printLValue(instr.lvalue)} = ${value}`; } else { - return value; + return `${id} ${value}`; } } diff --git a/compiler/forget/src/__tests__/fixtures/hir/call.expect.md b/compiler/forget/src/__tests__/fixtures/hir/call.expect.md index e4d0dcf1e0..6b4d89bee1 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/call.expect.md @@ -34,14 +34,14 @@ function foo$0() { ``` bb0: - Const mutate a$10 = Array [] - Const mutate b$11 = Object { } - Call mutate foo$4(mutate a$10, mutate b$11) - Const mutate $12 = "div" - Let mutate _$13 = JSX - Call mutate foo$4(mutate b$11) - Const mutate $14 = "div" - Const mutate $15 = JSX + [1] Const mutate a$10 = Array [] + [2] Const mutate b$11 = Object { } + [3] Call mutate foo$4(mutate a$10, mutate b$11) + [4] Const mutate $12 = "div" + [5] Let mutate _$13 = JSX + [6] Call mutate foo$4(mutate b$11) + [7] Const mutate $14 = "div" + [8] Const mutate $15 = JSX Return read $15 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md index 8bc690d69c..a76216d800 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md @@ -35,12 +35,12 @@ function Component(props) { ``` bb0: - Const mutate items$27 = read props$26.items - Const mutate maxItems$28 = read props$26.maxItems - Const mutate renderedItems$29 = Array [] - Const mutate seen$30 = New mutate Set$6() - Const mutate $31 = 0 - Const mutate max$32 = Call mutate Math$8.max(read $31, read maxItems$28) + [1] Const mutate items$27 = read props$26.items + [2] Const mutate maxItems$28 = read props$26.maxItems + [3] Const mutate renderedItems$29 = Array [] + [4] Const mutate seen$30 = New mutate Set$6() + [5] Const mutate $31 = 0 + [6] Const mutate max$32 = Call mutate Math$8.max(read $31, read maxItems$28) Goto bb1 bb1: predecessor blocks: bb0 bb4 bb7 @@ -52,16 +52,16 @@ bb1: If (read items$33) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - Const mutate $34 = null - Const mutate $36 = Binary read item$35 == read $34 + [7] Const mutate $34 = null + [8] Const mutate $36 = Binary read item$35 == read $34 If (read $36) then:bb8 else:bb9 bb8: predecessor blocks: bb3 - Const mutate $37 = read $36 + [9] Const mutate $37 = read $36 Goto bb7 bb9: predecessor blocks: bb3 - Const mutate $39 = Call mutate seen$38.has(mutate item$35) + [10] Const mutate $39 = Call mutate seen$38.has(mutate item$35) Goto bb7 bb7: predecessor blocks: bb9 bb8 @@ -69,23 +69,23 @@ bb7: If (read $40) then:bb1 else:bb4 bb4: predecessor blocks: bb7 - Call mutate seen$38.add(mutate item$35) - Const mutate $43 = "div" - Const mutate $44 = JSX {read item$35} - Call mutate renderedItems$46.push(read $44) - Const mutate $49 = Binary read renderedItems$46.length >= read max$48 + [11] Call mutate seen$38.add(mutate item$35) + [12] Const mutate $43 = "div" + [13] Const mutate $44 = JSX {read item$35} + [14] Call mutate renderedItems$46.push(read $44) + [15] Const mutate $49 = Binary read renderedItems$46.length >= read max$48 If (read $49) then:bb2 else:bb1 bb2: predecessor blocks: bb1 bb4 - Const mutate count$52 = read renderedItems$46.length - Const mutate $53 = "div" - Const mutate $54 = "\n " - Const mutate $55 = "h1" - Const mutate $56 = " Items" - Const mutate $57 = JSX {freeze count$52}{read $56} - Const mutate $58 = "\n " - Const mutate $59 = "\n " - Const mutate $60 = JSX {read $54}{read $57}{read $58}{freeze renderedItems$46}{read $59} + [16] Const mutate count$52 = read renderedItems$46.length + [17] Const mutate $53 = "div" + [18] Const mutate $54 = "\n " + [19] Const mutate $55 = "h1" + [20] Const mutate $56 = " Items" + [21] Const mutate $57 = JSX {freeze count$52}{read $56} + [22] Const mutate $58 = "\n " + [23] Const mutate $59 = "\n " + [24] Const mutate $60 = JSX {read $54}{read $57}{read $58}{freeze renderedItems$46}{read $59} Return read $60 ``` 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 b54e57a151..28f5d4c4db 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md @@ -78,16 +78,16 @@ function Component(props) { ``` bb0: - Const mutate a_DEBUG$5 = Array [] - Call mutate a_DEBUG$5.push(read props$4.a) + [1] Const mutate a_DEBUG$5 = Array [] + [2] Call mutate a_DEBUG$5.push(read props$4.a) If (read props$4.b) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Const mutate $6 = null + [3] Const mutate $6 = null Return read $6 bb1: predecessor blocks: bb0 - Call mutate a_DEBUG$5.push(read props$4.d) + [4] Call mutate a_DEBUG$5.push(read props$4.d) Return freeze a_DEBUG$5 ``` @@ -110,16 +110,16 @@ function Component$0(props$4) { ``` bb0: - Const mutate a$4 = Array [] - Call mutate a$4.push(read props$3.a) + [1] Const mutate a$4 = Array [] + [2] Call mutate a$4.push(read props$3.a) If (read props$3.b) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Call mutate a$4.push(read props$3.c) + [3] Call mutate a$4.push(read props$3.c) Goto bb1 bb1: predecessor blocks: bb0 bb2 - Call mutate a$4.push(read props$3.d) + [4] Call mutate a$4.push(read props$3.d) Return freeze a$4 ``` @@ -143,17 +143,17 @@ function Component$0(props$3) { ``` bb0: - Const mutate a$5 = Array [] - Call mutate a$5.push(read props$4.a) + [1] Const mutate a$5 = Array [] + [2] Call mutate a$5.push(read props$4.a) If (read props$4.b) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Call mutate a$5.push(read props$4.c) - Const mutate $6 = null + [3] Call mutate a$5.push(read props$4.c) + [4] Const mutate $6 = null Return read $6 bb1: predecessor blocks: bb0 - Call mutate a$5.push(read props$4.d) + [5] Call mutate a$5.push(read props$4.d) Return freeze a$5 ``` @@ -177,16 +177,16 @@ function Component$0(props$4) { ``` bb0: - Const mutate a$4 = Array [] - Call mutate a$4.push(read props$3.a) + [1] Const mutate a$4 = Array [] + [2] Call mutate a$4.push(read props$3.a) If (read props$3.b) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Call mutate a$4.push(read props$3.c) + [3] Call mutate a$4.push(read props$3.c) Return freeze a$4 bb1: predecessor blocks: bb0 - Call mutate a$4.push(read props$3.d) + [4] Call mutate a$4.push(read props$3.d) Return freeze a$4 ``` @@ -210,16 +210,16 @@ function Component$0(props$3) { ``` bb0: - Const mutate a$4 = Array [] - Call mutate a$4.push(read props$3.a) + [1] Const mutate a$4 = Array [] + [2] Call mutate a$4.push(read props$3.a) If (read props$3.b) then:bb1 else:bb2 bb2: predecessor blocks: bb0 - Call mutate a$4.push(read props$3.c) + [3] Call mutate a$4.push(read props$3.c) Goto bb1 bb1: predecessor blocks: bb2 bb0 - Call mutate a$4.push(read props$3.d) + [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 a77b2aad7b..626c0a99c3 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 @@ -67,23 +67,23 @@ function mayMutate() {} ``` bb0: - Const mutate a$7 = Array [] - Const mutate b$8 = Array [] + [1] Const mutate a$7 = Array [] + [2] Const mutate b$8 = Array [] If (read b$8) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Call mutate a$7.push(read props$6.p0) + [3] Call mutate a$7.push(read props$6.p0) Goto bb1 bb1: predecessor blocks: bb0 bb2 If (read props$6.p1) then:bb4 else:bb3 bb4: predecessor blocks: bb1 - Call mutate b$8.push(read props$6.p2) + [4] Call mutate b$8.push(read props$6.p2) Goto bb3 bb3: predecessor blocks: bb1 bb4 - Const mutate $16 = JSX + [5] Const mutate $16 = JSX Return read $16 ``` @@ -111,24 +111,24 @@ function Component$0(props$6) { ``` bb0: - Const mutate a$9 = Array [] - Const mutate b$10 = Array [] - Const mutate $11 = Call mutate mayMutate$4(mutate b$10) + [1] Const mutate a$9 = Array [] + [2] Const mutate b$10 = Array [] + [3] Const mutate $11 = Call mutate mayMutate$4(mutate b$10) If (read $11) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Call mutate a$9.push(read props$8.p0) + [4] Call mutate a$9.push(read props$8.p0) Goto bb1 bb1: predecessor blocks: bb0 bb2 If (read props$8.p1) then:bb4 else:bb3 bb4: predecessor blocks: bb1 - Call mutate b$10.push(read props$8.p2) + [5] Call mutate b$10.push(read props$8.p2) Goto bb3 bb3: predecessor blocks: bb1 bb4 - Const mutate $19 = JSX + [6] Const mutate $19 = JSX Return read $19 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md b/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md index 6b79bee31d..f30a6e0b8f 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md @@ -34,14 +34,14 @@ function Foo$0() { ``` bb0: - Const mutate a$10 = Array [] - Const mutate b$11 = Object { } - New mutate Foo$4(mutate a$10, mutate b$11) - Const mutate $12 = "div" - Let mutate _$13 = JSX - New mutate Foo$4(mutate b$11) - Const mutate $14 = "div" - Const mutate $15 = JSX + [1] Const mutate a$10 = Array [] + [2] Const mutate b$11 = Object { } + [3] New mutate Foo$4(mutate a$10, mutate b$11) + [4] Const mutate $12 = "div" + [5] Let mutate _$13 = JSX + [6] New mutate Foo$4(mutate b$11) + [7] Const mutate $14 = "div" + [8] Const mutate $15 = JSX Return read $15 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md b/compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md index bf745e9e4e..cecedebf17 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md @@ -18,10 +18,10 @@ function foo(x) {} ``` bb0: - Const mutate a$5 = Array [] - Const mutate b$6 = read a$5 - Call read useFreeze$3(freeze a$5) - Call mutate foo$4(read b$6) + [1] Const mutate a$5 = Array [] + [2] Const mutate b$6 = read a$5 + [3] Call read useFreeze$3(freeze a$5) + [4] Call mutate foo$4(read b$6) Return ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md b/compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md index 12d7dc54fd..2aeaa9552f 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md @@ -53,13 +53,13 @@ function foo$0() { ``` bb0: - Const mutate x$11 = Array [] - Const mutate y$12 = Call read useFreeze$4(freeze x$11) - Call mutate foo$5(read y$12, read x$11) - Const mutate $13 = "\n " - Const mutate $14 = "\n " - Const mutate $15 = "\n " - Const mutate $16 = JSX {read $13}{read x$11}{read $14}{read y$12}{read $15} + [1] Const mutate x$11 = Array [] + [2] Const mutate y$12 = Call read useFreeze$4(freeze x$11) + [3] Call mutate foo$5(read y$12, read x$11) + [4] Const mutate $13 = "\n " + [5] Const mutate $14 = "\n " + [6] Const mutate $15 = "\n " + [7] Const mutate $16 = JSX {read $13}{read x$11}{read $14}{read y$12}{read $15} Return read $16 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md b/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md index f5e9158fc0..43841c4c64 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md @@ -19,10 +19,10 @@ function call(x) {} ``` bb0: - Const mutate a$4 = Array [] - Call read useFreeze$2(freeze a$4) - Call read useFreeze$2(read a$4) - Call mutate call$3(read a$4) + [1] Const mutate a$4 = Array [] + [2] Call read useFreeze$2(freeze a$4) + [3] Call read useFreeze$2(read a$4) + [4] Call mutate call$3(read a$4) Return read a$4 ``` 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 ce9ad157e3..4572b6b99d 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 @@ -26,24 +26,24 @@ function call(x) {} ``` bb0: - Const mutate cond$8 = read props$7.cond - Const mutate x$9 = read props$7.x - Let mutate a$10 = undefined + [1] Const mutate cond$8 = read props$7.cond + [2] Const mutate x$9 = read props$7.x + [3] Let mutate a$10 = undefined If (read cond$8) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - Reassign mutate a$11 = read x$9 + [4] Reassign mutate a$11 = read x$9 Goto bb1 bb3: predecessor blocks: bb0 - Reassign mutate a$12 = Array [] + [5] Reassign mutate a$12 = Array [] Goto bb1 bb1: predecessor blocks: bb3 bb2 a$14: phi(bb3: a$12, bb2: a$11) - Call read useFreeze$5(freeze a$14) - Call read useFreeze$5(read a$14) - Call mutate call$6(read a$14) + [6] Call read useFreeze$5(freeze a$14) + [7] Call read useFreeze$5(read a$14) + [8] Call mutate call$6(read a$14) Return 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 975bccc9ce..d284f83424 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 @@ -97,17 +97,17 @@ function Foo$0() { ``` bb0: - Const mutate a$9 = Call mutate compute$3(read props$8.a) - Const mutate b$10 = Call mutate compute$3(read props$8.b) + [1] Const mutate a$9 = Call mutate compute$3(read props$8.a) + [2] Const mutate b$10 = Call mutate compute$3(read props$8.b) If (read props$8.c) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Call mutate mutate$5(mutate a$9) - Call mutate mutate$5(mutate b$10) + [3] Call mutate mutate$5(mutate a$9) + [4] Call mutate mutate$5(mutate b$10) Goto bb1 bb1: predecessor blocks: bb0 bb2 - Const mutate $14 = JSX + [5] Const mutate $14 = JSX Return read $14 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md b/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md index 2292bc702c..24b5b67c22 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md @@ -28,9 +28,9 @@ function Foo() {} ``` bb0: - Const mutate a$8 = Call mutate compute$3(read props$7.a) - Const mutate b$9 = Call mutate compute$3(read props$7.b) - Const mutate $10 = JSX + [1] Const mutate a$8 = Call mutate compute$3(read props$7.a) + [2] Const mutate b$9 = Call mutate compute$3(read props$7.b) + [3] Const mutate $10 = JSX Return read $10 ``` 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 331e700312..df4fc3170b 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 @@ -76,16 +76,16 @@ function Foo$0() { ``` bb0: - Const mutate a$9 = Call mutate compute$3(read props$8.a) - Const mutate b$10 = Call mutate compute$3(read props$8.b) + [1] Const mutate a$9 = Call mutate compute$3(read props$8.a) + [2] Const mutate b$10 = Call mutate compute$3(read props$8.b) If (read props$8.c) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Call mutate foo$5(mutate a$9, mutate b$10) + [3] Call mutate foo$5(mutate a$9, mutate b$10) Goto bb1 bb1: predecessor blocks: bb0 bb2 - Const mutate $14 = JSX + [4] Const mutate $14 = JSX Return read $14 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md b/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md index 9edcd21830..605ea980de 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md @@ -28,10 +28,10 @@ function Foo() {} ``` bb0: - Const mutate a$9 = Call mutate compute$3(read props$8.a) - Const mutate b$10 = Call mutate compute$3(read props$8.b) - Call mutate foo$5(mutate a$9, mutate b$10) - Const mutate $11 = JSX + [1] Const mutate a$9 = Call mutate compute$3(read props$8.a) + [2] Const mutate b$10 = Call mutate compute$3(read props$8.b) + [3] Call mutate foo$5(mutate a$9, mutate b$10) + [4] Const mutate $11 = JSX Return read $11 ``` 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 212e23f61f..fd0ba8ce8a 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md @@ -23,15 +23,15 @@ function g() {} ``` bb0: - Const mutate $5 = Call mutate f$1() + [1] Const mutate $5 = Call mutate f$1() If (read $5) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - Const mutate $6 = Call mutate g$4() + [2] Const mutate $6 = Call mutate g$4() Goto bb1 bb3: predecessor blocks: bb0 - Const mutate $7 = read $5 + [3] Const mutate $7 = read $5 Goto bb1 bb1: predecessor blocks: bb3 bb2 @@ -56,15 +56,15 @@ function And$0() { ``` bb0: - Const mutate $5 = Call mutate f$1() + [1] Const mutate $5 = Call mutate f$1() If (read $5) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - Const mutate $6 = read $5 + [2] Const mutate $6 = read $5 Goto bb1 bb3: predecessor blocks: bb0 - Const mutate $7 = Call mutate g$4() + [3] Const mutate $7 = Call mutate g$4() Goto bb1 bb1: predecessor blocks: bb3 bb2 @@ -89,17 +89,17 @@ function Or$0() { ``` bb0: - Const mutate $9 = Call mutate f$2() - Const mutate $10 = null - Const mutate $11 = Binary read $9 != read $10 + [1] Const mutate $9 = Call mutate f$2() + [2] Const mutate $10 = null + [3] Const mutate $11 = Binary read $9 != read $10 If (read $11) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - Const mutate $12 = read $9 + [4] Const mutate $12 = read $9 Goto bb1 bb3: predecessor blocks: bb0 - Const mutate $13 = Call mutate g$7() + [5] Const mutate $13 = Call mutate g$7() Goto bb1 bb1: predecessor blocks: bb3 bb2 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 aee9e8df6c..30ee6eb4fd 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 @@ -73,10 +73,10 @@ function cond$0(x$2) { ``` bb0: - Let mutate a$13 = Object { } - Let mutate b$14 = Object { } - Let mutate c$15 = Object { } - Let mutate d$16 = Object { } + [1] Let mutate a$13 = Object { } + [2] Let mutate b$14 = Object { } + [3] Let mutate c$15 = Object { } + [4] Let mutate d$16 = Object { } Goto bb1 bb1: predecessor blocks: bb0 bb3 @@ -86,17 +86,17 @@ bb1: d$24: phi(bb0: d$16, bb3: d$26) mutate$27: phi(bb0: mutate$7, bb3: mutate$27) cond$28: phi(bb0: cond$8, bb3: cond$28) - Const mutate $17 = true + [5] Const mutate $17 = true If (read $17) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - Let mutate z$19 = read a$18 - Reassign mutate a$21 = read b$20 - Reassign mutate b$23 = read c$22 - Reassign mutate c$25 = read d$24 - Reassign mutate d$26 = read z$19 - Call mutate mutate$27(mutate a$21, mutate b$23) - Const mutate $29 = Call mutate cond$28(mutate a$21) + [6] Let mutate z$19 = read a$18 + [7] Reassign mutate a$21 = read b$20 + [8] Reassign mutate b$23 = read c$22 + [9] Reassign mutate c$25 = read d$24 + [10] Reassign mutate d$26 = read z$19 + [11] Call mutate mutate$27(mutate a$21, mutate b$23) + [12] Const mutate $29 = Call mutate cond$28(mutate a$21) If (read $29) then:bb2 else:bb1 bb2: predecessor blocks: bb1 bb3 @@ -116,8 +116,8 @@ bb11: If (read d$33) then:bb13 else:bb13 bb13: predecessor blocks: bb11 - Const mutate $34 = null - Call mutate mutate$27(mutate d$33, read $34) + [13] Const mutate $34 = null + [14] Call mutate mutate$27(mutate d$33, read $34) Return ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md b/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md index b9ffe4ca10..27a16c6523 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md @@ -54,13 +54,13 @@ function mutate$0(x$3, y$4) { ``` bb0: - Const mutate a$11 = Object { } - Const mutate b$12 = Array [read a$11] - Const mutate c$13 = Object { } - Const mutate d$14 = Object { c: read c$13 } - Const mutate x$15 = Object { } - Reassign mutate x$15.b = read b$12 - Const mutate y$16 = Call mutate mutate$8(mutate x$15, mutate d$14) + [1] Const mutate a$11 = Object { } + [2] Const mutate b$12 = Array [read a$11] + [3] Const mutate c$13 = Object { } + [4] Const mutate d$14 = Object { c: read c$13 } + [5] Const mutate x$15 = Object { } + [6] Reassign mutate x$15.b = read b$12 + [7] Const mutate y$16 = Call mutate mutate$8(mutate x$15, mutate d$14) If (read a$11) then:bb1 else:bb1 bb1: predecessor blocks: bb0 @@ -76,8 +76,8 @@ bb7: If (read y$16) then:bb9 else:bb9 bb9: predecessor blocks: bb7 - Const mutate $17 = null - Call mutate mutate$8(mutate x$15, read $17) + [8] Const mutate $17 = null + [9] Call mutate mutate$8(mutate x$15, read $17) Return ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md b/compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md index da9e4b209a..2cfc0b6f18 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md @@ -17,12 +17,12 @@ function Component(props) { ``` bb0: - Const mutate x$7 = Object { } - Const mutate y$8 = Array [] - Reassign mutate x$7.y = read y$8 - Const mutate child$9 = JSX - Call mutate x$7.y.push(read props$6.p0) - Const mutate $10 = JSX {read child$9} + [1] Const mutate x$7 = Object { } + [2] Const mutate y$8 = Array [] + [3] Reassign mutate x$7.y = read y$8 + [4] Const mutate child$9 = JSX + [5] Call mutate x$7.y.push(read props$6.p0) + [6] Const mutate $10 = JSX {read child$9} Return read $10 ``` 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 a9cef1b263..8fb855cc49 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md @@ -23,20 +23,20 @@ function Component(props) { ``` bb0: - Let mutate x$7 = Array [] - Call mutate x$7.push(read props$6.p0) - Let mutate y$8 = read x$7 + [1] Let mutate x$7 = Array [] + [2] Call mutate x$7.push(read props$6.p0) + [3] Let mutate y$8 = read x$7 If (read props$6.p1) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Reassign mutate x$9 = Array [] + [4] Reassign mutate x$9 = Array [] Goto bb1 bb1: predecessor blocks: bb0 bb2 x$11: phi(bb0: x$7, bb2: x$9) - Let mutate _$12 = JSX - Call read y$8.push(read props$6.p2) - Const mutate $15 = JSX + [5] Let mutate _$12 = JSX + [6] Call read y$8.push(read props$6.p2) + [7] Const mutate $15 = JSX Return read $15 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md index f061ee199f..82422ddac2 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md @@ -21,13 +21,13 @@ function Component(props) { ``` bb0: - Let mutate x$7 = Array [] - Call mutate x$7.push(read props$6.p0) - Let mutate y$8 = read x$7 - Reassign mutate x$9 = Array [] - Let mutate _$10 = JSX - Call mutate y$8.push(read props$6.p1) - Const mutate $11 = JSX + [1] Let mutate x$7 = Array [] + [2] Call mutate x$7.push(read props$6.p0) + [3] Let mutate y$8 = read x$7 + [4] Reassign mutate x$9 = Array [] + [5] Let mutate _$10 = JSX + [6] Call mutate y$8.push(read props$6.p1) + [7] Const mutate $11 = JSX Return read $11 ``` 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 93ab89000e..d39df1c928 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md @@ -36,13 +36,13 @@ function Component(props) { ``` bb0: - Let mutate x$7 = undefined + [1] Let mutate x$7 = undefined If (read props$6.cond) then:bb2 else:bb10 bb2: predecessor blocks: bb0 - Const mutate $8 = 2 - Const mutate $9 = 1 - Const mutate $10 = 0 + [2] Const mutate $8 = 2 + [3] Const mutate $9 = 1 + [4] Const mutate $10 = 0 Switch ( props$6.test) Case read $10: bb8 Case read $9: bb6 @@ -50,31 +50,31 @@ bb2: Default: bb4 bb8: predecessor blocks: bb2 - Reassign mutate x$11 = read props$6.v0 + [5] Reassign mutate x$11 = read props$6.v0 Goto bb1 bb6: predecessor blocks: bb2 - Reassign mutate x$12 = read props$6.v1 + [6] Reassign mutate x$12 = read props$6.v1 Goto bb1 bb4: predecessor blocks: bb2 - Reassign mutate x$13 = read props$6.v2 + [7] Reassign mutate x$13 = read props$6.v2 Goto bb1 bb10: predecessor blocks: bb0 If (read props$6.cond2) then:bb12 else:bb13 bb12: predecessor blocks: bb10 - Reassign mutate x$14 = read props$6.b + [8] Reassign mutate x$14 = read props$6.b Goto bb1 bb13: predecessor blocks: bb10 - Reassign mutate x$15 = read props$6.c + [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) - read x$16 + [10] read x$16 Return ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md b/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md index 950c65842d..47bedb33ee 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md @@ -18,14 +18,14 @@ bb0: If (read x$8) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Const mutate $10 = false - Const mutate $11 = Call read foo$0(read $10, read y$9) + [1] Const mutate $10 = false + [2] Const mutate $11 = Call read foo$0(read $10, read y$9) Return freeze $11 bb1: predecessor blocks: bb0 - Const mutate $12 = 10 - Const mutate $13 = Binary read y$9 * read $12 - Const mutate $14 = Array [read $13] + [3] Const mutate $12 = 10 + [4] Const mutate $13 = Binary read y$9 * read $12 + [5] Const mutate $14 = Array [read $13] Return freeze $14 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md index dc9042fc64..19b29ff95c 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md @@ -15,9 +15,9 @@ function Component(props) { ``` bb0: - Const mutate a$6 = 1 - Const mutate b$7 = 2 - Const mutate x$8 = Array [read a$6, read b$7] + [1] Const mutate a$6 = 1 + [2] Const mutate b$7 = 2 + [3] Const mutate x$8 = Array [read a$6, read b$7] Return freeze x$8 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md index e4d0dcf1e0..6b4d89bee1 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md @@ -34,14 +34,14 @@ function foo$0() { ``` bb0: - Const mutate a$10 = Array [] - Const mutate b$11 = Object { } - Call mutate foo$4(mutate a$10, mutate b$11) - Const mutate $12 = "div" - Let mutate _$13 = JSX - Call mutate foo$4(mutate b$11) - Const mutate $14 = "div" - Const mutate $15 = JSX + [1] Const mutate a$10 = Array [] + [2] Const mutate b$11 = Object { } + [3] Call mutate foo$4(mutate a$10, mutate b$11) + [4] Const mutate $12 = "div" + [5] Let mutate _$13 = JSX + [6] Call mutate foo$4(mutate b$11) + [7] Const mutate $14 = "div" + [8] Const mutate $15 = JSX Return read $15 ``` 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 e4cb54c56a..71d82b5c4d 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 @@ -21,29 +21,29 @@ function foo() { ``` bb0: - Let mutate x$7 = 1 - Let mutate y$8 = 2 - Const mutate $9 = 2 - Const mutate $10 = Binary read y$8 === read $9 + [1] Let mutate x$7 = 1 + [2] Let mutate y$8 = 2 + [3] Const mutate $9 = 2 + [4] Const mutate $10 = Binary read y$8 === read $9 If (read $10) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Reassign mutate x$11 = 3 + [5] Reassign mutate x$11 = 3 Goto bb1 bb1: predecessor blocks: bb0 bb2 x$17: phi(bb0: x$7, bb2: x$11) - Const mutate $12 = 3 - Const mutate $14 = Binary read y$8 === read $12 + [6] Const mutate $12 = 3 + [7] Const mutate $14 = Binary read y$8 === read $12 If (read $14) then:bb4 else:bb3 bb4: predecessor blocks: bb1 - Reassign mutate x$15 = 5 + [8] Reassign mutate x$15 = 5 Goto bb3 bb3: predecessor blocks: bb1 bb4 x$16: phi(bb1: x$17, bb4: x$15) - Reassign mutate y$18 = read x$16 + [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 4a62eaf600..68bce41d37 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 @@ -18,19 +18,19 @@ function foo() { ``` bb0: - Let mutate x$5 = 1 - Let mutate y$6 = 2 - Const mutate $7 = 2 - Const mutate $8 = Binary read y$6 === read $7 + [1] Let mutate x$5 = 1 + [2] Let mutate y$6 = 2 + [3] Const mutate $7 = 2 + [4] Const mutate $8 = Binary read y$6 === read $7 If (read $8) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Reassign mutate x$9 = 3 + [5] Reassign mutate x$9 = 3 Goto bb1 bb1: predecessor blocks: bb0 bb2 x$10: phi(bb0: x$5, bb2: x$9) - Reassign mutate y$11 = read x$10 + [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 70f5016359..25089585b1 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 @@ -19,7 +19,7 @@ function foo(cond) { ``` bb0: - Let mutate items$5 = Array [] + [1] Let mutate items$5 = Array [] Goto bb1 bb1: predecessor blocks: bb0 bb3 bb5 @@ -28,11 +28,11 @@ bb1: If (read items$6) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - Let mutate y$7 = 0 + [2] Let mutate y$7 = 0 If (read cond$8) then:bb5 else:bb1 bb5: predecessor blocks: bb3 - Reassign mutate y$9 = 1 + [3] Reassign mutate y$9 = 1 Goto bb1 bb2: predecessor blocks: bb1 diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md index 65c52ad05a..408d658cee 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md @@ -16,18 +16,18 @@ function foo() { ``` bb0: - Let mutate x$5 = 0 + [1] Let mutate x$5 = 0 Goto bb1 bb1: predecessor blocks: bb0 bb4 x$7: phi(bb0: x$5, bb4: x$10) - Const mutate $6 = 10 - Const mutate $8 = Binary read x$7 < read $6 + [2] Const mutate $6 = 10 + [3] Const mutate $8 = Binary read x$7 < read $6 If (read $8) then:bb4 else:bb2 bb4: predecessor blocks: bb1 - Const mutate $9 = 1 - Reassign mutate x$10 = Binary read x$7 + read $9 + [4] Const mutate $9 = 1 + [5] Reassign mutate x$10 = Binary read x$7 + read $9 Goto bb1 bb2: 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 13a758602d..0e1063759b 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 @@ -19,16 +19,16 @@ function foo() { ``` bb0: - Let mutate x$5 = 1 - Let mutate y$6 = 2 + [1] Let mutate x$5 = 1 + [2] Let mutate y$6 = 2 If (read y$6) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - Let mutate z$7 = Binary read x$5 + read y$6 + [3] Let mutate z$7 = Binary read x$5 + read y$6 Goto bb1 bb3: predecessor blocks: bb0 - Let mutate z$8 = read x$5 + [4] Let mutate z$8 = read x$5 Goto bb1 bb1: predecessor blocks: bb3 bb2 diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md index b8388d3155..b8ecf3f4d4 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md @@ -32,9 +32,9 @@ function Foo$0() { ``` bb0: - Const mutate a$7 = Array [] - Const mutate b$8 = Object { } - Let mutate c$9 = New mutate Foo$5(mutate a$7, mutate b$8) + [1] Const mutate a$7 = Array [] + [2] Const mutate b$8 = Object { } + [3] Let mutate c$9 = New mutate Foo$5(mutate a$7, mutate b$8) Return freeze c$9 ``` 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 de9c059128..b9459ed34e 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 @@ -22,24 +22,24 @@ function foo() { ``` bb0: - Let mutate x$6 = 1 - Let mutate y$7 = 2 - Const mutate $8 = 1 - Const mutate $9 = Binary read x$6 > read $8 + [1] Let mutate x$6 = 1 + [2] Let mutate y$7 = 2 + [3] Const mutate $8 = 1 + [4] Const mutate $9 = Binary read x$6 > read $8 If (read $9) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - Reassign mutate x$10 = 2 + [5] Reassign mutate x$10 = 2 Goto bb1 bb3: predecessor blocks: bb0 - Reassign mutate y$11 = 3 + [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) - Let mutate t$14 = Object { x: read x$12, y: read y$13 } + [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-objectexpression.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md index 6d3ce5c94b..6d30e24098 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md @@ -15,9 +15,9 @@ function Component(props) { ``` bb0: - Const mutate a$6 = 1 - Const mutate b$7 = 2 - Const mutate x$8 = Object { a: read a$6, b: read b$7 } + [1] Const mutate a$6 = 1 + [2] Const mutate b$7 = 2 + [3] Const mutate x$8 = Object { a: read a$6, b: read b$7 } Return freeze x$8 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md index 4d26420dbd..bf7ef0f1c6 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md @@ -15,10 +15,10 @@ function foo() { ``` bb0: - Const mutate x$4 = Array [] - Const mutate y$5 = Object { x: read x$4 } - Const mutate $6 = Array [] - Call mutate y$5.x.push(mutate $6) + [1] Const mutate x$4 = Array [] + [2] Const mutate y$5 = Object { x: read x$4 } + [3] Const mutate $6 = Array [] + [4] Call mutate y$5.x.push(mutate $6) Return freeze y$5 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md index d3cc631513..87434143ca 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md @@ -15,9 +15,9 @@ function foo() { ``` bb0: - Const mutate x$3 = Array [] - Const mutate y$4 = Object { } - Reassign mutate y$4.x = read x$3 + [1] Const mutate x$3 = Array [] + [2] Const mutate y$4 = Object { } + [3] Reassign mutate y$4.x = read x$3 Return freeze y$4 ``` 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 4bf1b0294f..8c7c5be957 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md @@ -17,13 +17,13 @@ function foo() { ``` bb0: - Let mutate x$4 = 1 - Const mutate $5 = 1 - Const mutate $6 = Binary read x$4 === read $5 + [1] Let mutate x$4 = 1 + [2] Const mutate $5 = 1 + [3] Const mutate $6 = Binary read x$4 === read $5 If (read $6) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Reassign mutate x$7 = 2 + [4] Reassign mutate x$7 = 2 Goto bb1 bb1: predecessor blocks: bb0 bb2 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 11c54248d1..08c43662d3 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 @@ -20,22 +20,22 @@ function foo() { ``` bb0: - Let mutate y$5 = 2 - Const mutate $6 = 1 - Const mutate $7 = Binary read y$5 > read $6 + [1] Let mutate y$5 = 2 + [2] Const mutate $6 = 1 + [3] Const mutate $7 = Binary read y$5 > read $6 If (read $7) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - Reassign mutate y$8 = 1 + [4] Reassign mutate y$8 = 1 Goto bb1 bb3: predecessor blocks: bb0 - Reassign mutate y$9 = 2 + [5] Reassign mutate y$9 = 2 Goto bb1 bb1: predecessor blocks: bb3 bb2 y$10: phi(bb3: y$9, bb2: y$8) - Let mutate x$11 = read y$10 + [6] Let mutate x$11 = read y$10 Return ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md index 5e57e56d29..b99f9e9874 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md @@ -13,8 +13,8 @@ function foo() { ``` bb0: - Let mutate x$3 = 1 - Let mutate y$4 = 2 + [1] Let mutate x$3 = 1 + [2] Let mutate y$4 = 2 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 b56f3f48d3..bbd0b8499c 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 @@ -17,12 +17,12 @@ function foo() { ``` bb0: - Let mutate x$4 = 1 - Let mutate y$5 = 2 + [1] Let mutate x$4 = 1 + [2] Let mutate y$5 = 2 If (read y$5) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Let mutate z$6 = Binary read x$4 + read y$5 + [3] Let mutate z$6 = Binary read x$4 + read y$5 Goto bb1 bb1: predecessor blocks: bb0 bb2 diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md index 537adb4939..1d67a73019 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md @@ -28,34 +28,34 @@ function foo() { ``` bb0: - Let mutate x$10 = 1 - Const mutate $11 = 2 - Const mutate $12 = Binary read x$10 === read $11 - Const mutate $13 = 1 - Const mutate $14 = Binary read x$10 === read $13 + [1] Let mutate x$10 = 1 + [2] Const mutate $11 = 2 + [3] Const mutate $12 = Binary read x$10 === read $11 + [4] Const mutate $13 = 1 + [5] Const mutate $14 = Binary read x$10 === read $13 Switch ( x$10) Case read $14: bb5 Case read $12: bb3 Default: bb2 bb5: predecessor blocks: bb0 - Const mutate $15 = 1 - Reassign mutate x$16 = Binary read x$10 + read $15 + [6] Const mutate $15 = 1 + [7] Reassign mutate x$16 = Binary read x$10 + read $15 Goto bb1 bb3: predecessor blocks: bb0 - Const mutate $17 = 2 - Reassign mutate x$18 = Binary read x$10 + read $17 + [8] Const mutate $17 = 2 + [9] Reassign mutate x$18 = Binary read x$10 + read $17 Goto bb1 bb2: predecessor blocks: bb0 - Const mutate $19 = 3 - Reassign mutate x$20 = Binary read x$10 + read $19 + [10] Const mutate $19 = 3 + [11] Reassign mutate x$20 = Binary read x$10 + read $19 Goto bb1 bb1: predecessor blocks: bb5 bb3 bb2 x$21: phi(bb5: x$16, bb3: x$18, bb2: x$20) - Let mutate y$22 = read x$21 + [12] Let mutate y$22 = read x$21 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 5b5dfc127a..504f6a72e4 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md @@ -16,13 +16,13 @@ function foo() { ``` bb0: - Let mutate x$4 = 1 - Const mutate $5 = 1 - Const mutate $6 = Binary read x$4 === read $5 + [1] Let mutate x$4 = 1 + [2] Const mutate $5 = 1 + [3] Const mutate $6 = Binary read x$4 === read $5 If (read $6) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - Reassign mutate x$7 = 2 + [4] Reassign mutate x$7 = 2 Goto bb1 bb1: predecessor blocks: bb0 bb2 diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md index 2a741a330d..35b563716a 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md @@ -17,18 +17,18 @@ function foo() { ``` bb0: - Let mutate x$5 = 1 + [1] Let mutate x$5 = 1 Goto bb1 bb1: predecessor blocks: bb0 bb3 x$7: phi(bb0: x$5, bb3: x$10) - Const mutate $6 = 10 - Const mutate $8 = Binary read x$7 < read $6 + [2] Const mutate $6 = 10 + [3] Const mutate $8 = Binary read x$7 < read $6 If (read $8) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - Const mutate $9 = 1 - Reassign mutate x$10 = Binary read x$7 + read $9 + [4] Const mutate $9 = 1 + [5] Reassign mutate x$10 = Binary read x$7 + read $9 Goto bb1 bb2: predecessor blocks: bb1 diff --git a/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md b/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md index 153648e33f..4c5272940f 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md @@ -32,11 +32,11 @@ function Component(props) { ``` bb0: - Let mutate x$10 = Array [] - Let mutate y$11 = undefined - Const mutate $12 = false - Const mutate $13 = true - Const mutate $14 = 1 + [1] Let mutate x$10 = Array [] + [2] Let mutate y$11 = undefined + [3] Const mutate $12 = false + [4] Const mutate $13 = true + [5] Const mutate $14 = 1 Switch ( props$9.p0) Case read $14: bb1 Case read $13: bb6 @@ -44,19 +44,19 @@ bb0: Case read $12: bb2 bb6: predecessor blocks: bb0 - Call mutate x$10.push(read props$9.p2) - Reassign mutate y$15 = Array [] + [6] Call mutate x$10.push(read props$9.p2) + [7] Reassign mutate y$15 = Array [] Goto bb1 bb2: predecessor blocks: bb0 - Reassign mutate y$16 = read x$10 + [8] Reassign mutate y$16 = read x$10 Goto bb1 bb1: predecessor blocks: bb0 bb6 bb2 y$20: phi(bb0: y$11, bb6: y$15, bb2: y$16) - Const mutate child$19 = JSX - Call read y$20.push(read props$9.p4) - Const mutate $22 = JSX {read child$19} + [9] Const mutate child$19 = JSX + [10] Call read y$20.push(read props$9.p4) + [11] Const mutate $22 = JSX {read child$19} Return read $22 ``` diff --git a/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md b/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md index 7fe21624d7..06766890c0 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md @@ -28,30 +28,30 @@ function Component(props) { ``` bb0: - Let mutate x$9 = Array [] - Let mutate y$10 = undefined - Const mutate $11 = false - Const mutate $12 = true + [1] Let mutate x$9 = Array [] + [2] Let mutate y$10 = undefined + [3] Const mutate $11 = false + [4] Const mutate $12 = true Switch ( props$8.p0) Case read $12: bb4 Case read $11: bb2 Default: bb1 bb4: predecessor blocks: bb0 - Call mutate x$9.push(read props$8.p2) - Call mutate x$9.push(read props$8.p3) - Reassign mutate y$13 = Array [] + [5] Call mutate x$9.push(read props$8.p2) + [6] Call mutate x$9.push(read props$8.p3) + [7] Reassign mutate y$13 = Array [] Goto bb2 bb2: predecessor blocks: bb4 bb0 - Reassign mutate y$15 = read x$9 + [8] Reassign mutate y$15 = read x$9 Goto bb1 bb1: predecessor blocks: bb2 bb0 y$20: phi(bb2: y$15, bb0: y$10) - Const mutate child$19 = JSX - Call read y$20.push(read props$8.p4) - Const mutate $23 = JSX {read child$19} + [9] Const mutate child$19 = JSX + [10] Call read y$20.push(read props$8.p4) + [11] Const mutate $23 = JSX {read child$19} Return read $23 ```