[hir] Add id to number Instruction
Sathya Gunasekaran committed
Nov 4, 2022 at 16:39 UTC
e69888054c7afcc9d37e52ac47b7bd606dc4a49b
46 files changed
+325
-299
compiler/forget/src/HIR/BuildHIR.ts
+12
@@ -582,6 +582,7 @@ function lowerStatement(
582
};
583
}
584
builder.push({
585
+ id: 0,
586
lvalue: { place: id, kind },
587
value,
588
loc: declaration.node.loc ?? GeneratedSource,
@@ -598,6 +599,7 @@ function lowerStatement(
599
return;
600
}
601
builder.push({
602
+ id: 0,
603
lvalue: null,
604
value,
605
loc: stmt.node.loc ?? GeneratedSource,
@@ -636,6 +638,7 @@ function lowerStatement(
638
case "TSTypeAliasDeclaration":
639
case "WithStatement": {
640
builder.push({
641
+ id: 0,
642
lvalue: null,
643
loc: stmtPath.node.loc ?? GeneratedSource,
644
value: {
@@ -835,6 +838,7 @@ function lowerExpression(
838
loc: left.loc,
839
};
840
builder.push({
841
+ id: 0,
842
value: {
843
kind: "Primitive",
844
value: null,
@@ -852,6 +856,7 @@ function lowerExpression(
856
loc: left.loc,
857
};
858
builder.push({
859
+ id: 0,
860
lvalue: {
861
place: { ...condPlace },
862
kind: InstructionKind.Const,
@@ -888,6 +893,7 @@ function lowerExpression(
893
const operator = expr.node.operator;
894
todoInvariant(operator === "=", "todo: support non-simple assignment");
895
builder.push({
896
+ id: 0,
897
lvalue: { place: left, kind: InstructionKind.Reassign },
898
value: right,
899
loc: exprLoc,
@@ -981,6 +987,7 @@ function lowerConditional(
987
const consequentBlock = builder.enter((blockId) => {
988
let value = consequent();
989
builder.push({
990
+ id: 0,
991
value,
992
lvalue: { place: { ...place }, kind: InstructionKind.Const },
993
loc: value.loc,
@@ -994,6 +1001,7 @@ function lowerConditional(
1001
const alternateBlock = builder.enter((blockId) => {
1002
let value = alternate();
1003
builder.push({
1004
+ id: 0,
1005
value,
1006
lvalue: { place: { ...place }, kind: InstructionKind.Const },
1007
loc: value.loc,
@@ -1049,6 +1057,7 @@ function lowerJsxElementName(
1057
loc: exprLoc,
1058
};
1059
builder.push({
1060
+ id: 0,
1061
value: {
1062
kind: "Primitive",
1063
value: tag,
@@ -1088,6 +1097,7 @@ function lowerJsxElement(
1097
loc: exprLoc,
1098
};
1099
builder.push({
1100
+ id: 0,
1101
value: {
1102
kind: "JSXText",
1103
value: exprPath.node.value,
@@ -1110,6 +1120,7 @@ function lowerJsxElement(
1120
loc: exprLoc,
1121
};
1122
builder.push({
1123
+ id: 0,
1124
value: {
1125
kind: "OtherStatement",
1126
node: exprNode,
@@ -1139,6 +1150,7 @@ function lowerExpressionToPlace(
1150
loc: exprLoc,
1151
};
1152
builder.push({
1153
+ id: 0,
1154
value: instr,
1155
loc: exprLoc,
1156
lvalue: { place: { ...place }, kind: InstructionKind.Const },
compiler/forget/src/HIR/HIR.ts
+1
@@ -149,6 +149,7 @@ export type SwitchTerminal = {
149
* or may occur only for side-effects (many expression statements).
150
*/
151
export type Instruction = {
152
+ id: number;
153
lvalue: LValue | null;
154
value: InstructionValue;
155
loc: SourceLocation;
compiler/forget/src/HIR/HIRBuilder.ts
+12
@@ -18,6 +18,7 @@ import {
18
makeBlockId,
19
Terminal,
20
} from "./HIR";
21
+import { printInstruction } from "./PrintHIR";
22
23
// *******************************************************************************************
24
// *******************************************************************************************
@@ -147,6 +148,7 @@ export default class HIRBuilder {
148
});
149
// then convert to reverse postorder
150
const blocks = reversePostorderBlocks(reduced);
151
+ markInstructionIds(blocks);
152
markPredecessors(blocks);
153
return blocks;
154
}
@@ -483,6 +485,16 @@ function reversePostorderBlocks(func: HIR): HIR {
485
};
486
}
487
488
+function markInstructionIds(func: HIR) {
489
+ let id = 0;
490
+ for (const [_, block] of func.blocks) {
491
+ for (const instr of block.instructions) {
492
+ invariant(instr.id === 0, `${printInstruction(instr)} already visited!`);
493
+ instr.id = ++id;
494
+ }
495
+ }
496
+}
497
+
498
function markPredecessors(func: HIR) {
499
const visited: Set<BlockId> = new Set();
500
function visit(blockId: BlockId, prevBlock?: BasicBlock) {
compiler/forget/src/HIR/PrintHIR.ts
+4
-3
@@ -82,13 +82,14 @@ export function printMixedHIR(
82
}
83
}
84
85
-function printInstruction(instr: Instruction): string {
85
+export function printInstruction(instr: Instruction): string {
86
+ const id = `[${instr.id}]`;
87
const value = printInstructionValue(instr.value);
88
89
if (instr.lvalue !== null) {
89
- return `${printLValue(instr.lvalue)} = ${value}`;
90
+ return `${id} ${printLValue(instr.lvalue)} = ${value}`;
91
} else {
91
- return value;
92
+ return `${id} ${value}`;
93
}
94
}
95
compiler/forget/src/__tests__/fixtures/hir/call.expect.md
+8
-8
@@ -34,14 +34,14 @@ function foo$0() {
34
35
```
36
bb0:
37
- Const mutate a$10 = Array []
38
- Const mutate b$11 = Object { }
39
- Call mutate foo$4(mutate a$10, mutate b$11)
40
- Const mutate $12 = "div"
41
- Let mutate _$13 = JSX <read $12 a={freeze a$10} ></read $12>
42
- Call mutate foo$4(mutate b$11)
43
- Const mutate $14 = "div"
44
- Const mutate $15 = JSX <read $14 a={read a$10} b={freeze b$11} ></read $14>
37
+ [1] Const mutate a$10 = Array []
38
+ [2] Const mutate b$11 = Object { }
39
+ [3] Call mutate foo$4(mutate a$10, mutate b$11)
40
+ [4] Const mutate $12 = "div"
41
+ [5] Let mutate _$13 = JSX <read $12 a={freeze a$10} ></read $12>
42
+ [6] Call mutate foo$4(mutate b$11)
43
+ [7] Const mutate $14 = "div"
44
+ [8] Const mutate $15 = JSX <read $14 a={read a$10} b={freeze b$11} ></read $14>
45
Return read $15
46
```
47
compiler/forget/src/__tests__/fixtures/hir/component.expect.md
+24
-24
@@ -35,12 +35,12 @@ function Component(props) {
35
36
```
37
bb0:
38
- Const mutate items$27 = read props$26.items
39
- Const mutate maxItems$28 = read props$26.maxItems
40
- Const mutate renderedItems$29 = Array []
41
- Const mutate seen$30 = New mutate Set$6()
42
- Const mutate $31 = 0
43
- Const mutate max$32 = Call mutate Math$8.max(read $31, read maxItems$28)
38
+ [1] Const mutate items$27 = read props$26.items
39
+ [2] Const mutate maxItems$28 = read props$26.maxItems
40
+ [3] Const mutate renderedItems$29 = Array []
41
+ [4] Const mutate seen$30 = New mutate Set$6()
42
+ [5] Const mutate $31 = 0
43
+ [6] Const mutate max$32 = Call mutate Math$8.max(read $31, read maxItems$28)
44
Goto bb1
45
bb1:
46
predecessor blocks: bb0 bb4 bb7
@@ -52,16 +52,16 @@ bb1:
52
If (read items$33) then:bb3 else:bb2
53
bb3:
54
predecessor blocks: bb1
55
- Const mutate $34 = null
56
- Const mutate $36 = Binary read item$35 == read $34
55
+ [7] Const mutate $34 = null
56
+ [8] Const mutate $36 = Binary read item$35 == read $34
57
If (read $36) then:bb8 else:bb9
58
bb8:
59
predecessor blocks: bb3
60
- Const mutate $37 = read $36
60
+ [9] Const mutate $37 = read $36
61
Goto bb7
62
bb9:
63
predecessor blocks: bb3
64
- Const mutate $39 = Call mutate seen$38.has(mutate item$35)
64
+ [10] Const mutate $39 = Call mutate seen$38.has(mutate item$35)
65
Goto bb7
66
bb7:
67
predecessor blocks: bb9 bb8
@@ -69,23 +69,23 @@ bb7:
69
If (read $40) then:bb1 else:bb4
70
bb4:
71
predecessor blocks: bb7
72
- Call mutate seen$38.add(mutate item$35)
73
- Const mutate $43 = "div"
74
- Const mutate $44 = JSX <read $43>{read item$35}</read $43>
75
- Call mutate renderedItems$46.push(read $44)
76
- Const mutate $49 = Binary read renderedItems$46.length >= read max$48
72
+ [11] Call mutate seen$38.add(mutate item$35)
73
+ [12] Const mutate $43 = "div"
74
+ [13] Const mutate $44 = JSX <read $43>{read item$35}</read $43>
75
+ [14] Call mutate renderedItems$46.push(read $44)
76
+ [15] Const mutate $49 = Binary read renderedItems$46.length >= read max$48
77
If (read $49) then:bb2 else:bb1
78
bb2:
79
predecessor blocks: bb1 bb4
80
- Const mutate count$52 = read renderedItems$46.length
81
- Const mutate $53 = "div"
82
- Const mutate $54 = "\n "
83
- Const mutate $55 = "h1"
84
- Const mutate $56 = " Items"
85
- Const mutate $57 = JSX <read $55>{freeze count$52}{read $56}</read $55>
86
- Const mutate $58 = "\n "
87
- Const mutate $59 = "\n "
88
- Const mutate $60 = JSX <read $53>{read $54}{read $57}{read $58}{freeze renderedItems$46}{read $59}</read $53>
80
+ [16] Const mutate count$52 = read renderedItems$46.length
81
+ [17] Const mutate $53 = "div"
82
+ [18] Const mutate $54 = "\n "
83
+ [19] Const mutate $55 = "h1"
84
+ [20] Const mutate $56 = " Items"
85
+ [21] Const mutate $57 = JSX <read $55>{freeze count$52}{read $56}</read $55>
86
+ [22] Const mutate $58 = "\n "
87
+ [23] Const mutate $59 = "\n "
88
+ [24] Const mutate $60 = JSX <read $53>{read $54}{read $57}{read $58}{freeze renderedItems$46}{read $59}</read $53>
89
Return read $60
90
```
91
compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md
+21
-21
@@ -78,16 +78,16 @@ function Component(props) {
78
79
```
80
bb0:
81
- Const mutate a_DEBUG$5 = Array []
82
- Call mutate a_DEBUG$5.push(read props$4.a)
81
+ [1] Const mutate a_DEBUG$5 = Array []
82
+ [2] Call mutate a_DEBUG$5.push(read props$4.a)
83
If (read props$4.b) then:bb2 else:bb1
84
bb2:
85
predecessor blocks: bb0
86
- Const mutate $6 = null
86
+ [3] Const mutate $6 = null
87
Return read $6
88
bb1:
89
predecessor blocks: bb0
90
- Call mutate a_DEBUG$5.push(read props$4.d)
90
+ [4] Call mutate a_DEBUG$5.push(read props$4.d)
91
Return freeze a_DEBUG$5
92
```
93
@@ -110,16 +110,16 @@ function Component$0(props$4) {
110
111
```
112
bb0:
113
- Const mutate a$4 = Array []
114
- Call mutate a$4.push(read props$3.a)
113
+ [1] Const mutate a$4 = Array []
114
+ [2] Call mutate a$4.push(read props$3.a)
115
If (read props$3.b) then:bb2 else:bb1
116
bb2:
117
predecessor blocks: bb0
118
- Call mutate a$4.push(read props$3.c)
118
+ [3] Call mutate a$4.push(read props$3.c)
119
Goto bb1
120
bb1:
121
predecessor blocks: bb0 bb2
122
- Call mutate a$4.push(read props$3.d)
122
+ [4] Call mutate a$4.push(read props$3.d)
123
Return freeze a$4
124
```
125
@@ -143,17 +143,17 @@ function Component$0(props$3) {
143
144
```
145
bb0:
146
- Const mutate a$5 = Array []
147
- Call mutate a$5.push(read props$4.a)
146
+ [1] Const mutate a$5 = Array []
147
+ [2] Call mutate a$5.push(read props$4.a)
148
If (read props$4.b) then:bb2 else:bb1
149
bb2:
150
predecessor blocks: bb0
151
- Call mutate a$5.push(read props$4.c)
152
- Const mutate $6 = null
151
+ [3] Call mutate a$5.push(read props$4.c)
152
+ [4] Const mutate $6 = null
153
Return read $6
154
bb1:
155
predecessor blocks: bb0
156
- Call mutate a$5.push(read props$4.d)
156
+ [5] Call mutate a$5.push(read props$4.d)
157
Return freeze a$5
158
```
159
@@ -177,16 +177,16 @@ function Component$0(props$4) {
177
178
```
179
bb0:
180
- Const mutate a$4 = Array []
181
- Call mutate a$4.push(read props$3.a)
180
+ [1] Const mutate a$4 = Array []
181
+ [2] Call mutate a$4.push(read props$3.a)
182
If (read props$3.b) then:bb2 else:bb1
183
bb2:
184
predecessor blocks: bb0
185
- Call mutate a$4.push(read props$3.c)
185
+ [3] Call mutate a$4.push(read props$3.c)
186
Return freeze a$4
187
bb1:
188
predecessor blocks: bb0
189
- Call mutate a$4.push(read props$3.d)
189
+ [4] Call mutate a$4.push(read props$3.d)
190
Return freeze a$4
191
```
192
@@ -210,16 +210,16 @@ function Component$0(props$3) {
210
211
```
212
bb0:
213
- Const mutate a$4 = Array []
214
- Call mutate a$4.push(read props$3.a)
213
+ [1] Const mutate a$4 = Array []
214
+ [2] Call mutate a$4.push(read props$3.a)
215
If (read props$3.b) then:bb1 else:bb2
216
bb2:
217
predecessor blocks: bb0
218
- Call mutate a$4.push(read props$3.c)
218
+ [3] Call mutate a$4.push(read props$3.c)
219
Goto bb1
220
bb1:
221
predecessor blocks: bb2 bb0
222
- Call mutate a$4.push(read props$3.d)
222
+ [4] Call mutate a$4.push(read props$3.d)
223
Return freeze a$4
224
```
225
compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md
+11
-11
@@ -67,23 +67,23 @@ function mayMutate() {}
67
68
```
69
bb0:
70
- Const mutate a$7 = Array []
71
- Const mutate b$8 = Array []
70
+ [1] Const mutate a$7 = Array []
71
+ [2] Const mutate b$8 = Array []
72
If (read b$8) then:bb2 else:bb1
73
bb2:
74
predecessor blocks: bb0
75
- Call mutate a$7.push(read props$6.p0)
75
+ [3] Call mutate a$7.push(read props$6.p0)
76
Goto bb1
77
bb1:
78
predecessor blocks: bb0 bb2
79
If (read props$6.p1) then:bb4 else:bb3
80
bb4:
81
predecessor blocks: bb1
82
- Call mutate b$8.push(read props$6.p2)
82
+ [4] Call mutate b$8.push(read props$6.p2)
83
Goto bb3
84
bb3:
85
predecessor blocks: bb1 bb4
86
- Const mutate $16 = JSX <read Foo$4 a={freeze a$7} b={freeze b$8} ></read Foo$4>
86
+ [5] Const mutate $16 = JSX <read Foo$4 a={freeze a$7} b={freeze b$8} ></read Foo$4>
87
Return read $16
88
```
89
@@ -111,24 +111,24 @@ function Component$0(props$6) {
111
112
```
113
bb0:
114
- Const mutate a$9 = Array []
115
- Const mutate b$10 = Array []
116
- Const mutate $11 = Call mutate mayMutate$4(mutate b$10)
114
+ [1] Const mutate a$9 = Array []
115
+ [2] Const mutate b$10 = Array []
116
+ [3] Const mutate $11 = Call mutate mayMutate$4(mutate b$10)
117
If (read $11) then:bb2 else:bb1
118
bb2:
119
predecessor blocks: bb0
120
- Call mutate a$9.push(read props$8.p0)
120
+ [4] Call mutate a$9.push(read props$8.p0)
121
Goto bb1
122
bb1:
123
predecessor blocks: bb0 bb2
124
If (read props$8.p1) then:bb4 else:bb3
125
bb4:
126
predecessor blocks: bb1
127
- Call mutate b$10.push(read props$8.p2)
127
+ [5] Call mutate b$10.push(read props$8.p2)
128
Goto bb3
129
bb3:
130
predecessor blocks: bb1 bb4
131
- Const mutate $19 = JSX <read Foo$6 a={freeze a$9} b={freeze b$10} ></read Foo$6>
131
+ [6] Const mutate $19 = JSX <read Foo$6 a={freeze a$9} b={freeze b$10} ></read Foo$6>
132
Return read $19
133
```
134
compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md
+8
-8
@@ -34,14 +34,14 @@ function Foo$0() {
34
35
```
36
bb0:
37
- Const mutate a$10 = Array []
38
- Const mutate b$11 = Object { }
39
- New mutate Foo$4(mutate a$10, mutate b$11)
40
- Const mutate $12 = "div"
41
- Let mutate _$13 = JSX <read $12 a={freeze a$10} ></read $12>
42
- New mutate Foo$4(mutate b$11)
43
- Const mutate $14 = "div"
44
- Const mutate $15 = JSX <read $14 a={read a$10} b={freeze b$11} ></read $14>
37
+ [1] Const mutate a$10 = Array []
38
+ [2] Const mutate b$11 = Object { }
39
+ [3] New mutate Foo$4(mutate a$10, mutate b$11)
40
+ [4] Const mutate $12 = "div"
41
+ [5] Let mutate _$13 = JSX <read $12 a={freeze a$10} ></read $12>
42
+ [6] New mutate Foo$4(mutate b$11)
43
+ [7] Const mutate $14 = "div"
44
+ [8] Const mutate $15 = JSX <read $14 a={read a$10} b={freeze b$11} ></read $14>
45
Return read $15
46
```
47
compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md
+4
-4
@@ -18,10 +18,10 @@ function foo(x) {}
18
19
```
20
bb0:
21
- Const mutate a$5 = Array []
22
- Const mutate b$6 = read a$5
23
- Call read useFreeze$3(freeze a$5)
24
- Call mutate foo$4(read b$6)
21
+ [1] Const mutate a$5 = Array []
22
+ [2] Const mutate b$6 = read a$5
23
+ [3] Call read useFreeze$3(freeze a$5)
24
+ [4] Call mutate foo$4(read b$6)
25
Return
26
```
27
compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md
+7
-7
@@ -53,13 +53,13 @@ function foo$0() {
53
54
```
55
bb0:
56
- Const mutate x$11 = Array []
57
- Const mutate y$12 = Call read useFreeze$4(freeze x$11)
58
- Call mutate foo$5(read y$12, read x$11)
59
- Const mutate $13 = "\n "
60
- Const mutate $14 = "\n "
61
- Const mutate $15 = "\n "
62
- Const mutate $16 = JSX <read Component$0>{read $13}{read x$11}{read $14}{read y$12}{read $15}</read Component$0>
56
+ [1] Const mutate x$11 = Array []
57
+ [2] Const mutate y$12 = Call read useFreeze$4(freeze x$11)
58
+ [3] Call mutate foo$5(read y$12, read x$11)
59
+ [4] Const mutate $13 = "\n "
60
+ [5] Const mutate $14 = "\n "
61
+ [6] Const mutate $15 = "\n "
62
+ [7] Const mutate $16 = JSX <read Component$0>{read $13}{read x$11}{read $14}{read y$12}{read $15}</read Component$0>
63
Return read $16
64
```
65
compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md
+4
-4
@@ -19,10 +19,10 @@ function call(x) {}
19
20
```
21
bb0:
22
- Const mutate a$4 = Array []
23
- Call read useFreeze$2(freeze a$4)
24
- Call read useFreeze$2(read a$4)
25
- Call mutate call$3(read a$4)
22
+ [1] Const mutate a$4 = Array []
23
+ [2] Call read useFreeze$2(freeze a$4)
24
+ [3] Call read useFreeze$2(read a$4)
25
+ [4] Call mutate call$3(read a$4)
26
Return read a$4
27
```
28
compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md
+8
-8
@@ -26,24 +26,24 @@ function call(x) {}
26
27
```
28
bb0:
29
- Const mutate cond$8 = read props$7.cond
30
- Const mutate x$9 = read props$7.x
31
- Let mutate a$10 = undefined
29
+ [1] Const mutate cond$8 = read props$7.cond
30
+ [2] Const mutate x$9 = read props$7.x
31
+ [3] Let mutate a$10 = undefined
32
If (read cond$8) then:bb2 else:bb3
33
bb2:
34
predecessor blocks: bb0
35
- Reassign mutate a$11 = read x$9
35
+ [4] Reassign mutate a$11 = read x$9
36
Goto bb1
37
bb3:
38
predecessor blocks: bb0
39
- Reassign mutate a$12 = Array []
39
+ [5] Reassign mutate a$12 = Array []
40
Goto bb1
41
bb1:
42
predecessor blocks: bb3 bb2
43
a$14: phi(bb3: a$12, bb2: a$11)
44
- Call read useFreeze$5(freeze a$14)
45
- Call read useFreeze$5(read a$14)
46
- Call mutate call$6(read a$14)
44
+ [6] Call read useFreeze$5(freeze a$14)
45
+ [7] Call read useFreeze$5(read a$14)
46
+ [8] Call mutate call$6(read a$14)
47
Return read a$14
48
```
49
compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md
+5
-5
@@ -97,17 +97,17 @@ function Foo$0() {
97
98
```
99
bb0:
100
- Const mutate a$9 = Call mutate compute$3(read props$8.a)
101
- Const mutate b$10 = Call mutate compute$3(read props$8.b)
100
+ [1] Const mutate a$9 = Call mutate compute$3(read props$8.a)
101
+ [2] Const mutate b$10 = Call mutate compute$3(read props$8.b)
102
If (read props$8.c) then:bb2 else:bb1
103
bb2:
104
predecessor blocks: bb0
105
- Call mutate mutate$5(mutate a$9)
106
- Call mutate mutate$5(mutate b$10)
105
+ [3] Call mutate mutate$5(mutate a$9)
106
+ [4] Call mutate mutate$5(mutate b$10)
107
Goto bb1
108
bb1:
109
predecessor blocks: bb0 bb2
110
- Const mutate $14 = JSX <read Foo$6 a={freeze a$9} b={freeze b$10} ></read Foo$6>
110
+ [5] Const mutate $14 = JSX <read Foo$6 a={freeze a$9} b={freeze b$10} ></read Foo$6>
111
Return read $14
112
```
113
compiler/forget/src/__tests__/fixtures/hir/independent.expect.md
+3
-3
@@ -28,9 +28,9 @@ function Foo() {}
28
29
```
30
bb0:
31
- Const mutate a$8 = Call mutate compute$3(read props$7.a)
32
- Const mutate b$9 = Call mutate compute$3(read props$7.b)
33
- Const mutate $10 = JSX <read Foo$5 a={freeze a$8} b={freeze b$9} ></read Foo$5>
31
+ [1] Const mutate a$8 = Call mutate compute$3(read props$7.a)
32
+ [2] Const mutate b$9 = Call mutate compute$3(read props$7.b)
33
+ [3] Const mutate $10 = JSX <read Foo$5 a={freeze a$8} b={freeze b$9} ></read Foo$5>
34
Return read $10
35
```
36
compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md
+4
-4
@@ -76,16 +76,16 @@ function Foo$0() {
76
77
```
78
bb0:
79
- Const mutate a$9 = Call mutate compute$3(read props$8.a)
80
- Const mutate b$10 = Call mutate compute$3(read props$8.b)
79
+ [1] Const mutate a$9 = Call mutate compute$3(read props$8.a)
80
+ [2] Const mutate b$10 = Call mutate compute$3(read props$8.b)
81
If (read props$8.c) then:bb2 else:bb1
82
bb2:
83
predecessor blocks: bb0
84
- Call mutate foo$5(mutate a$9, mutate b$10)
84
+ [3] Call mutate foo$5(mutate a$9, mutate b$10)
85
Goto bb1
86
bb1:
87
predecessor blocks: bb0 bb2
88
- Const mutate $14 = JSX <read Foo$6 a={freeze a$9} b={freeze b$10} ></read Foo$6>
88
+ [4] Const mutate $14 = JSX <read Foo$6 a={freeze a$9} b={freeze b$10} ></read Foo$6>
89
Return read $14
90
```
91
compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md
+4
-4
@@ -28,10 +28,10 @@ function Foo() {}
28
29
```
30
bb0:
31
- Const mutate a$9 = Call mutate compute$3(read props$8.a)
32
- Const mutate b$10 = Call mutate compute$3(read props$8.b)
33
- Call mutate foo$5(mutate a$9, mutate b$10)
34
- Const mutate $11 = JSX <read Foo$6 a={freeze a$9} b={freeze b$10} ></read Foo$6>
31
+ [1] Const mutate a$9 = Call mutate compute$3(read props$8.a)
32
+ [2] Const mutate b$10 = Call mutate compute$3(read props$8.b)
33
+ [3] Call mutate foo$5(mutate a$9, mutate b$10)
34
+ [4] Const mutate $11 = JSX <read Foo$6 a={freeze a$9} b={freeze b$10} ></read Foo$6>
35
Return read $11
36
```
37
compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md
+11
-11
@@ -23,15 +23,15 @@ function g() {}
23
24
```
25
bb0:
26
- Const mutate $5 = Call mutate f$1()
26
+ [1] Const mutate $5 = Call mutate f$1()
27
If (read $5) then:bb2 else:bb3
28
bb2:
29
predecessor blocks: bb0
30
- Const mutate $6 = Call mutate g$4()
30
+ [2] Const mutate $6 = Call mutate g$4()
31
Goto bb1
32
bb3:
33
predecessor blocks: bb0
34
- Const mutate $7 = read $5
34
+ [3] Const mutate $7 = read $5
35
Goto bb1
36
bb1:
37
predecessor blocks: bb3 bb2
@@ -56,15 +56,15 @@ function And$0() {
56
57
```
58
bb0:
59
- Const mutate $5 = Call mutate f$1()
59
+ [1] Const mutate $5 = Call mutate f$1()
60
If (read $5) then:bb2 else:bb3
61
bb2:
62
predecessor blocks: bb0
63
- Const mutate $6 = read $5
63
+ [2] Const mutate $6 = read $5
64
Goto bb1
65
bb3:
66
predecessor blocks: bb0
67
- Const mutate $7 = Call mutate g$4()
67
+ [3] Const mutate $7 = Call mutate g$4()
68
Goto bb1
69
bb1:
70
predecessor blocks: bb3 bb2
@@ -89,17 +89,17 @@ function Or$0() {
89
90
```
91
bb0:
92
- Const mutate $9 = Call mutate f$2()
93
- Const mutate $10 = null
94
- Const mutate $11 = Binary read $9 != read $10
92
+ [1] Const mutate $9 = Call mutate f$2()
93
+ [2] Const mutate $10 = null
94
+ [3] Const mutate $11 = Binary read $9 != read $10
95
If (read $11) then:bb2 else:bb3
96
bb2:
97
predecessor blocks: bb0
98
- Const mutate $12 = read $9
98
+ [4] Const mutate $12 = read $9
99
Goto bb1
100
bb3:
101
predecessor blocks: bb0
102
- Const mutate $13 = Call mutate g$7()
102
+ [5] Const mutate $13 = Call mutate g$7()
103
Goto bb1
104
bb1:
105
predecessor blocks: bb3 bb2
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md
+14
-14
@@ -73,10 +73,10 @@ function cond$0(x$2) {
73
74
```
75
bb0:
76
- Let mutate a$13 = Object { }
77
- Let mutate b$14 = Object { }
78
- Let mutate c$15 = Object { }
79
- Let mutate d$16 = Object { }
76
+ [1] Let mutate a$13 = Object { }
77
+ [2] Let mutate b$14 = Object { }
78
+ [3] Let mutate c$15 = Object { }
79
+ [4] Let mutate d$16 = Object { }
80
Goto bb1
81
bb1:
82
predecessor blocks: bb0 bb3
@@ -86,17 +86,17 @@ bb1:
86
d$24: phi(bb0: d$16, bb3: d$26)
87
mutate$27: phi(bb0: mutate$7, bb3: mutate$27)
88
cond$28: phi(bb0: cond$8, bb3: cond$28)
89
- Const mutate $17 = true
89
+ [5] Const mutate $17 = true
90
If (read $17) then:bb3 else:bb2
91
bb3:
92
predecessor blocks: bb1
93
- Let mutate z$19 = read a$18
94
- Reassign mutate a$21 = read b$20
95
- Reassign mutate b$23 = read c$22
96
- Reassign mutate c$25 = read d$24
97
- Reassign mutate d$26 = read z$19
98
- Call mutate mutate$27(mutate a$21, mutate b$23)
99
- Const mutate $29 = Call mutate cond$28(mutate a$21)
93
+ [6] Let mutate z$19 = read a$18
94
+ [7] Reassign mutate a$21 = read b$20
95
+ [8] Reassign mutate b$23 = read c$22
96
+ [9] Reassign mutate c$25 = read d$24
97
+ [10] Reassign mutate d$26 = read z$19
98
+ [11] Call mutate mutate$27(mutate a$21, mutate b$23)
99
+ [12] Const mutate $29 = Call mutate cond$28(mutate a$21)
100
If (read $29) then:bb2 else:bb1
101
bb2:
102
predecessor blocks: bb1 bb3
@@ -116,8 +116,8 @@ bb11:
116
If (read d$33) then:bb13 else:bb13
117
bb13:
118
predecessor blocks: bb11
119
- Const mutate $34 = null
120
- Call mutate mutate$27(mutate d$33, read $34)
119
+ [13] Const mutate $34 = null
120
+ [14] Call mutate mutate$27(mutate d$33, read $34)
121
Return
122
```
123
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md
+9
-9
@@ -54,13 +54,13 @@ function mutate$0(x$3, y$4) {
54
55
```
56
bb0:
57
- Const mutate a$11 = Object { }
58
- Const mutate b$12 = Array [read a$11]
59
- Const mutate c$13 = Object { }
60
- Const mutate d$14 = Object { c: read c$13 }
61
- Const mutate x$15 = Object { }
62
- Reassign mutate x$15.b = read b$12
63
- Const mutate y$16 = Call mutate mutate$8(mutate x$15, mutate d$14)
57
+ [1] Const mutate a$11 = Object { }
58
+ [2] Const mutate b$12 = Array [read a$11]
59
+ [3] Const mutate c$13 = Object { }
60
+ [4] Const mutate d$14 = Object { c: read c$13 }
61
+ [5] Const mutate x$15 = Object { }
62
+ [6] Reassign mutate x$15.b = read b$12
63
+ [7] Const mutate y$16 = Call mutate mutate$8(mutate x$15, mutate d$14)
64
If (read a$11) then:bb1 else:bb1
65
bb1:
66
predecessor blocks: bb0
@@ -76,8 +76,8 @@ bb7:
76
If (read y$16) then:bb9 else:bb9
77
bb9:
78
predecessor blocks: bb7
79
- Const mutate $17 = null
80
- Call mutate mutate$8(mutate x$15, read $17)
79
+ [8] Const mutate $17 = null
80
+ [9] Call mutate mutate$8(mutate x$15, read $17)
81
Return
82
```
83
compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md
+6
-6
@@ -17,12 +17,12 @@ function Component(props) {
17
18
```
19
bb0:
20
- Const mutate x$7 = Object { }
21
- Const mutate y$8 = Array []
22
- Reassign mutate x$7.y = read y$8
23
- Const mutate child$9 = JSX <read Component$0 data={freeze y$8} ></read Component$0>
24
- Call mutate x$7.y.push(read props$6.p0)
25
- Const mutate $10 = JSX <read Component$0 data={freeze x$7} >{read child$9}</read Component$0>
20
+ [1] Const mutate x$7 = Object { }
21
+ [2] Const mutate y$8 = Array []
22
+ [3] Reassign mutate x$7.y = read y$8
23
+ [4] Const mutate child$9 = JSX <read Component$0 data={freeze y$8} ></read Component$0>
24
+ [5] Call mutate x$7.y.push(read props$6.p0)
25
+ [6] Const mutate $10 = JSX <read Component$0 data={freeze x$7} >{read child$9}</read Component$0>
26
Return read $10
27
```
28
compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md
+7
-7
@@ -23,20 +23,20 @@ function Component(props) {
23
24
```
25
bb0:
26
- Let mutate x$7 = Array []
27
- Call mutate x$7.push(read props$6.p0)
28
- Let mutate y$8 = read x$7
26
+ [1] Let mutate x$7 = Array []
27
+ [2] Call mutate x$7.push(read props$6.p0)
28
+ [3] Let mutate y$8 = read x$7
29
If (read props$6.p1) then:bb2 else:bb1
30
bb2:
31
predecessor blocks: bb0
32
- Reassign mutate x$9 = Array []
32
+ [4] Reassign mutate x$9 = Array []
33
Goto bb1
34
bb1:
35
predecessor blocks: bb0 bb2
36
x$11: phi(bb0: x$7, bb2: x$9)
37
- Let mutate _$12 = JSX <read Component$0 x={freeze x$11} ></read Component$0>
38
- Call read y$8.push(read props$6.p2)
39
- Const mutate $15 = JSX <read Component$0 x={read x$11} y={read y$8} ></read Component$0>
37
+ [5] Let mutate _$12 = JSX <read Component$0 x={freeze x$11} ></read Component$0>
38
+ [6] Call read y$8.push(read props$6.p2)
39
+ [7] Const mutate $15 = JSX <read Component$0 x={read x$11} y={read y$8} ></read Component$0>
40
Return read $15
41
```
42
compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md
+7
-7
@@ -21,13 +21,13 @@ function Component(props) {
21
22
```
23
bb0:
24
- Let mutate x$7 = Array []
25
- Call mutate x$7.push(read props$6.p0)
26
- Let mutate y$8 = read x$7
27
- Reassign mutate x$9 = Array []
28
- Let mutate _$10 = JSX <read Component$0 x={freeze x$9} ></read Component$0>
29
- Call mutate y$8.push(read props$6.p1)
30
- Const mutate $11 = JSX <read Component$0 x={read x$9} y={freeze y$8} ></read Component$0>
24
+ [1] Let mutate x$7 = Array []
25
+ [2] Call mutate x$7.push(read props$6.p0)
26
+ [3] Let mutate y$8 = read x$7
27
+ [4] Reassign mutate x$9 = Array []
28
+ [5] Let mutate _$10 = JSX <read Component$0 x={freeze x$9} ></read Component$0>
29
+ [6] Call mutate y$8.push(read props$6.p1)
30
+ [7] Const mutate $11 = JSX <read Component$0 x={read x$9} y={freeze y$8} ></read Component$0>
31
Return read $11
32
```
33
compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md
+10
-10
@@ -36,13 +36,13 @@ function Component(props) {
36
37
```
38
bb0:
39
- Let mutate x$7 = undefined
39
+ [1] Let mutate x$7 = undefined
40
If (read props$6.cond) then:bb2 else:bb10
41
bb2:
42
predecessor blocks: bb0
43
- Const mutate $8 = 2
44
- Const mutate $9 = 1
45
- Const mutate $10 = 0
43
+ [2] Const mutate $8 = 2
44
+ [3] Const mutate $9 = 1
45
+ [4] Const mutate $10 = 0
46
Switch (<unknown> props$6.test)
47
Case read $10: bb8
48
Case read $9: bb6
@@ -50,31 +50,31 @@ bb2:
50
Default: bb4
51
bb8:
52
predecessor blocks: bb2
53
- Reassign mutate x$11 = read props$6.v0
53
+ [5] Reassign mutate x$11 = read props$6.v0
54
Goto bb1
55
bb6:
56
predecessor blocks: bb2
57
- Reassign mutate x$12 = read props$6.v1
57
+ [6] Reassign mutate x$12 = read props$6.v1
58
Goto bb1
59
bb4:
60
predecessor blocks: bb2
61
- Reassign mutate x$13 = read props$6.v2
61
+ [7] Reassign mutate x$13 = read props$6.v2
62
Goto bb1
63
bb10:
64
predecessor blocks: bb0
65
If (read props$6.cond2) then:bb12 else:bb13
66
bb12:
67
predecessor blocks: bb10
68
- Reassign mutate x$14 = read props$6.b
68
+ [8] Reassign mutate x$14 = read props$6.b
69
Goto bb1
70
bb13:
71
predecessor blocks: bb10
72
- Reassign mutate x$15 = read props$6.c
72
+ [9] Reassign mutate x$15 = read props$6.c
73
Goto bb1
74
bb1:
75
predecessor blocks: bb13 bb12 bb8 bb6 bb4
76
x$16: phi(bb13: x$15, bb12: x$14, bb8: x$11, bb6: x$12, bb4: x$13)
77
- read x$16
77
+ [10] read x$16
78
Return
79
```
80
compiler/forget/src/__tests__/fixtures/hir/simple.expect.md
+5
-5
@@ -18,14 +18,14 @@ bb0:
18
If (read x$8) then:bb2 else:bb1
19
bb2:
20
predecessor blocks: bb0
21
- Const mutate $10 = false
22
- Const mutate $11 = Call read foo$0(read $10, read y$9)
21
+ [1] Const mutate $10 = false
22
+ [2] Const mutate $11 = Call read foo$0(read $10, read y$9)
23
Return freeze $11
24
bb1:
25
predecessor blocks: bb0
26
- Const mutate $12 = 10
27
- Const mutate $13 = Binary read y$9 * read $12
28
- Const mutate $14 = Array [read $13]
26
+ [3] Const mutate $12 = 10
27
+ [4] Const mutate $13 = Binary read y$9 * read $12
28
+ [5] Const mutate $14 = Array [read $13]
29
Return freeze $14
30
```
31
compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md
+3
-3
@@ -15,9 +15,9 @@ function Component(props) {
15
16
```
17
bb0:
18
- Const mutate a$6 = 1
19
- Const mutate b$7 = 2
20
- Const mutate x$8 = Array [read a$6, read b$7]
18
+ [1] Const mutate a$6 = 1
19
+ [2] Const mutate b$7 = 2
20
+ [3] Const mutate x$8 = Array [read a$6, read b$7]
21
Return freeze x$8
22
```
23
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md
+8
-8
@@ -34,14 +34,14 @@ function foo$0() {
34
35
```
36
bb0:
37
- Const mutate a$10 = Array []
38
- Const mutate b$11 = Object { }
39
- Call mutate foo$4(mutate a$10, mutate b$11)
40
- Const mutate $12 = "div"
41
- Let mutate _$13 = JSX <read $12 a={freeze a$10} ></read $12>
42
- Call mutate foo$4(mutate b$11)
43
- Const mutate $14 = "div"
44
- Const mutate $15 = JSX <read $14 a={read a$10} b={freeze b$11} ></read $14>
37
+ [1] Const mutate a$10 = Array []
38
+ [2] Const mutate b$11 = Object { }
39
+ [3] Call mutate foo$4(mutate a$10, mutate b$11)
40
+ [4] Const mutate $12 = "div"
41
+ [5] Let mutate _$13 = JSX <read $12 a={freeze a$10} ></read $12>
42
+ [6] Call mutate foo$4(mutate b$11)
43
+ [7] Const mutate $14 = "div"
44
+ [8] Const mutate $15 = JSX <read $14 a={read a$10} b={freeze b$11} ></read $14>
45
Return read $15
46
```
47
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md
+9
-9
@@ -21,29 +21,29 @@ function foo() {
21
22
```
23
bb0:
24
- Let mutate x$7 = 1
25
- Let mutate y$8 = 2
26
- Const mutate $9 = 2
27
- Const mutate $10 = Binary read y$8 === read $9
24
+ [1] Let mutate x$7 = 1
25
+ [2] Let mutate y$8 = 2
26
+ [3] Const mutate $9 = 2
27
+ [4] Const mutate $10 = Binary read y$8 === read $9
28
If (read $10) then:bb2 else:bb1
29
bb2:
30
predecessor blocks: bb0
31
- Reassign mutate x$11 = 3
31
+ [5] Reassign mutate x$11 = 3
32
Goto bb1
33
bb1:
34
predecessor blocks: bb0 bb2
35
x$17: phi(bb0: x$7, bb2: x$11)
36
- Const mutate $12 = 3
37
- Const mutate $14 = Binary read y$8 === read $12
36
+ [6] Const mutate $12 = 3
37
+ [7] Const mutate $14 = Binary read y$8 === read $12
38
If (read $14) then:bb4 else:bb3
39
bb4:
40
predecessor blocks: bb1
41
- Reassign mutate x$15 = 5
41
+ [8] Reassign mutate x$15 = 5
42
Goto bb3
43
bb3:
44
predecessor blocks: bb1 bb4
45
x$16: phi(bb1: x$17, bb4: x$15)
46
- Reassign mutate y$18 = read x$16
46
+ [9] Reassign mutate y$18 = read x$16
47
Return
48
```
49
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md
+6
-6
@@ -18,19 +18,19 @@ function foo() {
18
19
```
20
bb0:
21
- Let mutate x$5 = 1
22
- Let mutate y$6 = 2
23
- Const mutate $7 = 2
24
- Const mutate $8 = Binary read y$6 === read $7
21
+ [1] Let mutate x$5 = 1
22
+ [2] Let mutate y$6 = 2
23
+ [3] Const mutate $7 = 2
24
+ [4] Const mutate $8 = Binary read y$6 === read $7
25
If (read $8) then:bb2 else:bb1
26
bb2:
27
predecessor blocks: bb0
28
- Reassign mutate x$9 = 3
28
+ [5] Reassign mutate x$9 = 3
29
Goto bb1
30
bb1:
31
predecessor blocks: bb0 bb2
32
x$10: phi(bb0: x$5, bb2: x$9)
33
- Reassign mutate y$11 = read x$10
33
+ [6] Reassign mutate y$11 = read x$10
34
Return
35
```
36
compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md
+3
-3
@@ -19,7 +19,7 @@ function foo(cond) {
19
20
```
21
bb0:
22
- Let mutate items$5 = Array []
22
+ [1] Let mutate items$5 = Array []
23
Goto bb1
24
bb1:
25
predecessor blocks: bb0 bb3 bb5
@@ -28,11 +28,11 @@ bb1:
28
If (read items$6) then:bb3 else:bb2
29
bb3:
30
predecessor blocks: bb1
31
- Let mutate y$7 = 0
31
+ [2] Let mutate y$7 = 0
32
If (read cond$8) then:bb5 else:bb1
33
bb5:
34
predecessor blocks: bb3
35
- Reassign mutate y$9 = 1
35
+ [3] Reassign mutate y$9 = 1
36
Goto bb1
37
bb2:
38
predecessor blocks: bb1
compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md
+5
-5
@@ -16,18 +16,18 @@ function foo() {
16
17
```
18
bb0:
19
- Let mutate x$5 = 0
19
+ [1] Let mutate x$5 = 0
20
Goto bb1
21
bb1:
22
predecessor blocks: bb0 bb4
23
x$7: phi(bb0: x$5, bb4: x$10)
24
- Const mutate $6 = 10
25
- Const mutate $8 = Binary read x$7 < read $6
24
+ [2] Const mutate $6 = 10
25
+ [3] Const mutate $8 = Binary read x$7 < read $6
26
If (read $8) then:bb4 else:bb2
27
bb4:
28
predecessor blocks: bb1
29
- Const mutate $9 = 1
30
- Reassign mutate x$10 = Binary read x$7 + read $9
29
+ [4] Const mutate $9 = 1
30
+ [5] Reassign mutate x$10 = Binary read x$7 + read $9
31
Goto bb1
32
bb2:
33
predecessor blocks: bb1
compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md
+4
-4
@@ -19,16 +19,16 @@ function foo() {
19
20
```
21
bb0:
22
- Let mutate x$5 = 1
23
- Let mutate y$6 = 2
22
+ [1] Let mutate x$5 = 1
23
+ [2] Let mutate y$6 = 2
24
If (read y$6) then:bb2 else:bb3
25
bb2:
26
predecessor blocks: bb0
27
- Let mutate z$7 = Binary read x$5 + read y$6
27
+ [3] Let mutate z$7 = Binary read x$5 + read y$6
28
Goto bb1
29
bb3:
30
predecessor blocks: bb0
31
- Let mutate z$8 = read x$5
31
+ [4] Let mutate z$8 = read x$5
32
Goto bb1
33
bb1:
34
predecessor blocks: bb3 bb2
compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md
+3
-3
@@ -32,9 +32,9 @@ function Foo$0() {
32
33
```
34
bb0:
35
- Const mutate a$7 = Array []
36
- Const mutate b$8 = Object { }
37
- Let mutate c$9 = New mutate Foo$5(mutate a$7, mutate b$8)
35
+ [1] Const mutate a$7 = Array []
36
+ [2] Const mutate b$8 = Object { }
37
+ [3] Let mutate c$9 = New mutate Foo$5(mutate a$7, mutate b$8)
38
Return freeze c$9
39
```
40
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md
+7
-7
@@ -22,24 +22,24 @@ function foo() {
22
23
```
24
bb0:
25
- Let mutate x$6 = 1
26
- Let mutate y$7 = 2
27
- Const mutate $8 = 1
28
- Const mutate $9 = Binary read x$6 > read $8
25
+ [1] Let mutate x$6 = 1
26
+ [2] Let mutate y$7 = 2
27
+ [3] Const mutate $8 = 1
28
+ [4] Const mutate $9 = Binary read x$6 > read $8
29
If (read $9) then:bb2 else:bb3
30
bb2:
31
predecessor blocks: bb0
32
- Reassign mutate x$10 = 2
32
+ [5] Reassign mutate x$10 = 2
33
Goto bb1
34
bb3:
35
predecessor blocks: bb0
36
- Reassign mutate y$11 = 3
36
+ [6] Reassign mutate y$11 = 3
37
Goto bb1
38
bb1:
39
predecessor blocks: bb3 bb2
40
x$12: phi(bb3: x$6, bb2: x$10)
41
y$13: phi(bb3: y$11, bb2: y$7)
42
- Let mutate t$14 = Object { x: read x$12, y: read y$13 }
42
+ [7] Let mutate t$14 = Object { x: read x$12, y: read y$13 }
43
Return freeze t$14
44
```
45
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md
+3
-3
@@ -15,9 +15,9 @@ function Component(props) {
15
16
```
17
bb0:
18
- Const mutate a$6 = 1
19
- Const mutate b$7 = 2
20
- Const mutate x$8 = Object { a: read a$6, b: read b$7 }
18
+ [1] Const mutate a$6 = 1
19
+ [2] Const mutate b$7 = 2
20
+ [3] Const mutate x$8 = Object { a: read a$6, b: read b$7 }
21
Return freeze x$8
22
```
23
compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md
+4
-4
@@ -15,10 +15,10 @@ function foo() {
15
16
```
17
bb0:
18
- Const mutate x$4 = Array []
19
- Const mutate y$5 = Object { x: read x$4 }
20
- Const mutate $6 = Array []
21
- Call mutate y$5.x.push(mutate $6)
18
+ [1] Const mutate x$4 = Array []
19
+ [2] Const mutate y$5 = Object { x: read x$4 }
20
+ [3] Const mutate $6 = Array []
21
+ [4] Call mutate y$5.x.push(mutate $6)
22
Return freeze y$5
23
```
24
compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md
+3
-3
@@ -15,9 +15,9 @@ function foo() {
15
16
```
17
bb0:
18
- Const mutate x$3 = Array []
19
- Const mutate y$4 = Object { }
20
- Reassign mutate y$4.x = read x$3
18
+ [1] Const mutate x$3 = Array []
19
+ [2] Const mutate y$4 = Object { }
20
+ [3] Reassign mutate y$4.x = read x$3
21
Return freeze y$4
22
```
23
compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md
+4
-4
@@ -17,13 +17,13 @@ function foo() {
17
18
```
19
bb0:
20
- Let mutate x$4 = 1
21
- Const mutate $5 = 1
22
- Const mutate $6 = Binary read x$4 === read $5
20
+ [1] Let mutate x$4 = 1
21
+ [2] Const mutate $5 = 1
22
+ [3] Const mutate $6 = Binary read x$4 === read $5
23
If (read $6) then:bb2 else:bb1
24
bb2:
25
predecessor blocks: bb0
26
- Reassign mutate x$7 = 2
26
+ [4] Reassign mutate x$7 = 2
27
Goto bb1
28
bb1:
29
predecessor blocks: bb0 bb2
compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md
+6
-6
@@ -20,22 +20,22 @@ function foo() {
20
21
```
22
bb0:
23
- Let mutate y$5 = 2
24
- Const mutate $6 = 1
25
- Const mutate $7 = Binary read y$5 > read $6
23
+ [1] Let mutate y$5 = 2
24
+ [2] Const mutate $6 = 1
25
+ [3] Const mutate $7 = Binary read y$5 > read $6
26
If (read $7) then:bb2 else:bb3
27
bb2:
28
predecessor blocks: bb0
29
- Reassign mutate y$8 = 1
29
+ [4] Reassign mutate y$8 = 1
30
Goto bb1
31
bb3:
32
predecessor blocks: bb0
33
- Reassign mutate y$9 = 2
33
+ [5] Reassign mutate y$9 = 2
34
Goto bb1
35
bb1:
36
predecessor blocks: bb3 bb2
37
y$10: phi(bb3: y$9, bb2: y$8)
38
- Let mutate x$11 = read y$10
38
+ [6] Let mutate x$11 = read y$10
39
Return
40
```
41
compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md
+2
-2
@@ -13,8 +13,8 @@ function foo() {
13
14
```
15
bb0:
16
- Let mutate x$3 = 1
17
- Let mutate y$4 = 2
16
+ [1] Let mutate x$3 = 1
17
+ [2] Let mutate y$4 = 2
18
Return
19
```
20
compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md
+3
-3
@@ -17,12 +17,12 @@ function foo() {
17
18
```
19
bb0:
20
- Let mutate x$4 = 1
21
- Let mutate y$5 = 2
20
+ [1] Let mutate x$4 = 1
21
+ [2] Let mutate y$5 = 2
22
If (read y$5) then:bb2 else:bb1
23
bb2:
24
predecessor blocks: bb0
25
- Let mutate z$6 = Binary read x$4 + read y$5
25
+ [3] Let mutate z$6 = Binary read x$4 + read y$5
26
Goto bb1
27
bb1:
28
predecessor blocks: bb0 bb2
compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md
+12
-12
@@ -28,34 +28,34 @@ function foo() {
28
29
```
30
bb0:
31
- Let mutate x$10 = 1
32
- Const mutate $11 = 2
33
- Const mutate $12 = Binary read x$10 === read $11
34
- Const mutate $13 = 1
35
- Const mutate $14 = Binary read x$10 === read $13
31
+ [1] Let mutate x$10 = 1
32
+ [2] Const mutate $11 = 2
33
+ [3] Const mutate $12 = Binary read x$10 === read $11
34
+ [4] Const mutate $13 = 1
35
+ [5] Const mutate $14 = Binary read x$10 === read $13
36
Switch (<unknown> x$10)
37
Case read $14: bb5
38
Case read $12: bb3
39
Default: bb2
40
bb5:
41
predecessor blocks: bb0
42
- Const mutate $15 = 1
43
- Reassign mutate x$16 = Binary read x$10 + read $15
42
+ [6] Const mutate $15 = 1
43
+ [7] Reassign mutate x$16 = Binary read x$10 + read $15
44
Goto bb1
45
bb3:
46
predecessor blocks: bb0
47
- Const mutate $17 = 2
48
- Reassign mutate x$18 = Binary read x$10 + read $17
47
+ [8] Const mutate $17 = 2
48
+ [9] Reassign mutate x$18 = Binary read x$10 + read $17
49
Goto bb1
50
bb2:
51
predecessor blocks: bb0
52
- Const mutate $19 = 3
53
- Reassign mutate x$20 = Binary read x$10 + read $19
52
+ [10] Const mutate $19 = 3
53
+ [11] Reassign mutate x$20 = Binary read x$10 + read $19
54
Goto bb1
55
bb1:
56
predecessor blocks: bb5 bb3 bb2
57
x$21: phi(bb5: x$16, bb3: x$18, bb2: x$20)
58
- Let mutate y$22 = read x$21
58
+ [12] Let mutate y$22 = read x$21
59
Return
60
```
61
compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md
+4
-4
@@ -16,13 +16,13 @@ function foo() {
16
17
```
18
bb0:
19
- Let mutate x$4 = 1
20
- Const mutate $5 = 1
21
- Const mutate $6 = Binary read x$4 === read $5
19
+ [1] Let mutate x$4 = 1
20
+ [2] Const mutate $5 = 1
21
+ [3] Const mutate $6 = Binary read x$4 === read $5
22
If (read $6) then:bb2 else:bb1
23
bb2:
24
predecessor blocks: bb0
25
- Reassign mutate x$7 = 2
25
+ [4] Reassign mutate x$7 = 2
26
Goto bb1
27
bb1:
28
predecessor blocks: bb0 bb2
compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md
+5
-5
@@ -17,18 +17,18 @@ function foo() {
17
18
```
19
bb0:
20
- Let mutate x$5 = 1
20
+ [1] Let mutate x$5 = 1
21
Goto bb1
22
bb1:
23
predecessor blocks: bb0 bb3
24
x$7: phi(bb0: x$5, bb3: x$10)
25
- Const mutate $6 = 10
26
- Const mutate $8 = Binary read x$7 < read $6
25
+ [2] Const mutate $6 = 10
26
+ [3] Const mutate $8 = Binary read x$7 < read $6
27
If (read $8) then:bb3 else:bb2
28
bb3:
29
predecessor blocks: bb1
30
- Const mutate $9 = 1
31
- Reassign mutate x$10 = Binary read x$7 + read $9
30
+ [4] Const mutate $9 = 1
31
+ [5] Reassign mutate x$10 = Binary read x$7 + read $9
32
Goto bb1
33
bb2:
34
predecessor blocks: bb1
compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md
+11
-11
@@ -32,11 +32,11 @@ function Component(props) {
32
33
```
34
bb0:
35
- Let mutate x$10 = Array []
36
- Let mutate y$11 = undefined
37
- Const mutate $12 = false
38
- Const mutate $13 = true
39
- Const mutate $14 = 1
35
+ [1] Let mutate x$10 = Array []
36
+ [2] Let mutate y$11 = undefined
37
+ [3] Const mutate $12 = false
38
+ [4] Const mutate $13 = true
39
+ [5] Const mutate $14 = 1
40
Switch (<unknown> props$9.p0)
41
Case read $14: bb1
42
Case read $13: bb6
@@ -44,19 +44,19 @@ bb0:
44
Case read $12: bb2
45
bb6:
46
predecessor blocks: bb0
47
- Call mutate x$10.push(read props$9.p2)
48
- Reassign mutate y$15 = Array []
47
+ [6] Call mutate x$10.push(read props$9.p2)
48
+ [7] Reassign mutate y$15 = Array []
49
Goto bb1
50
bb2:
51
predecessor blocks: bb0
52
- Reassign mutate y$16 = read x$10
52
+ [8] Reassign mutate y$16 = read x$10
53
Goto bb1
54
bb1:
55
predecessor blocks: bb0 bb6 bb2
56
y$20: phi(bb0: y$11, bb6: y$15, bb2: y$16)
57
- Const mutate child$19 = JSX <read Component$0 data={freeze x$10} ></read Component$0>
58
- Call read y$20.push(read props$9.p4)
59
- Const mutate $22 = JSX <read Component$0 data={freeze y$20} >{read child$19}</read Component$0>
57
+ [9] Const mutate child$19 = JSX <read Component$0 data={freeze x$10} ></read Component$0>
58
+ [10] Call read y$20.push(read props$9.p4)
59
+ [11] Const mutate $22 = JSX <read Component$0 data={freeze y$20} >{read child$19}</read Component$0>
60
Return read $22
61
```
62
compiler/forget/src/__tests__/fixtures/hir/switch.expect.md
+11
-11
@@ -28,30 +28,30 @@ function Component(props) {
28
29
```
30
bb0:
31
- Let mutate x$9 = Array []
32
- Let mutate y$10 = undefined
33
- Const mutate $11 = false
34
- Const mutate $12 = true
31
+ [1] Let mutate x$9 = Array []
32
+ [2] Let mutate y$10 = undefined
33
+ [3] Const mutate $11 = false
34
+ [4] Const mutate $12 = true
35
Switch (<unknown> props$8.p0)
36
Case read $12: bb4
37
Case read $11: bb2
38
Default: bb1
39
bb4:
40
predecessor blocks: bb0
41
- Call mutate x$9.push(read props$8.p2)
42
- Call mutate x$9.push(read props$8.p3)
43
- Reassign mutate y$13 = Array []
41
+ [5] Call mutate x$9.push(read props$8.p2)
42
+ [6] Call mutate x$9.push(read props$8.p3)
43
+ [7] Reassign mutate y$13 = Array []
44
Goto bb2
45
bb2:
46
predecessor blocks: bb4 bb0
47
- Reassign mutate y$15 = read x$9
47
+ [8] Reassign mutate y$15 = read x$9
48
Goto bb1
49
bb1:
50
predecessor blocks: bb2 bb0
51
y$20: phi(bb2: y$15, bb0: y$10)
52
- Const mutate child$19 = JSX <read Component$0 data={freeze x$9} ></read Component$0>
53
- Call read y$20.push(read props$8.p4)
54
- Const mutate $23 = JSX <read Component$0 data={read y$20} >{read child$19}</read Component$0>
52
+ [9] Const mutate child$19 = JSX <read Component$0 data={freeze x$9} ></read Component$0>
53
+ [10] Call read y$20.push(read props$8.p4)
54
+ [11] Const mutate $23 = JSX <read Component$0 data={read y$20} >{read child$19}</read Component$0>
55
Return read $23
56
```
57