[ssa] Use Identifier for updating SSA
Instead of using Place, use Identifier as the unit of comparison in SSA. Place is too high level and can not be substituted for other Places (even those with the same Identifier) as Place contain higher level metadata such as memberPath.
Sathya Gunasekaran committed
Oct 27, 2022 at 14:11 UTC
c8aaa7f172cb8c5d879c226058d6a2e877a32955
22 files changed
+208
-149
compiler/forget/src/HIR/HIR.ts
+2
-2
@@ -166,8 +166,8 @@ export type InstructionValue = (InstructionData & { path: NodePath }) | Place;
166
167
export type Phi = {
168
kind: "Phi";
169
- lvalue: LValue;
170
- operands: Map<BasicBlock, Place>;
169
+ id: Identifier;
170
+ operands: Map<BasicBlock, Identifier>;
171
};
172
173
export type InstructionData =
compiler/forget/src/HIR/PrintHIR.ts
+9
-10
@@ -8,6 +8,7 @@
8
import { assertExhaustive } from "../Common/utils";
9
import {
10
HIR,
11
+ Identifier,
12
Instruction,
13
InstructionKind,
14
InstructionValue,
@@ -91,11 +92,11 @@ function printInstruction(instr: Instruction): string {
92
93
function printPhi(phi: Phi): string {
94
const items = [];
94
- items.push(printLValue(phi.lvalue));
95
+ items.push(printIdentifier(phi.id));
96
items.push(": phi(");
97
const phis = [];
97
- for (const [block, place] of phi.operands) {
98
- phis.push(`bb${block.id}: ${printPlace(place)}`);
98
+ for (const [block, id] of phi.operands) {
99
+ phis.push(`bb${block.id}: ${printIdentifier(id)}`);
100
}
101
102
items.push(phis.join(", "));
@@ -256,13 +257,7 @@ export function printLValue(lval: LValue): string {
257
}
258
259
export function printPlace(place: Place): string {
259
- const items = [
260
- place.effect,
261
- " ",
262
- place.identifier.name,
263
- "$",
264
- place.identifier.id,
265
- ];
260
+ const items = [place.effect, " ", printIdentifier(place.identifier)];
261
if (place.memberPath != null) {
262
for (const path of place.memberPath) {
263
items.push(".");
@@ -271,3 +266,7 @@ export function printPlace(place: Place): string {
266
}
267
return items.filter((x) => x != null).join("");
268
}
269
+
270
+export function printIdentifier(id: Identifier): string {
271
+ return `${id.name ?? ""}\$${id.id}`;
272
+}
compiler/forget/src/HIR/SSAify.ts
+39
-62
@@ -3,24 +3,22 @@ import { assertExhaustive } from "../Common/utils";
3
import {
4
BasicBlock,
5
BlockId,
6
- Effect,
6
HIRFunction,
8
- IdentifierId,
7
+ Identifier,
8
Instruction,
10
- InstructionKind,
9
Phi,
10
Place,
11
} from "./HIR";
12
import { Environment } from "./HIRBuilder";
15
-import { printPlace } from "./PrintHIR";
13
+import { printIdentifier } from "./PrintHIR";
14
15
type IncompletePhi = {
18
- old: Place;
19
- new: Place;
16
+ oldId: Identifier;
17
+ newId: Identifier;
18
};
19
20
type State = {
23
- defs: Map<IdentifierId, Place>;
21
+ defs: Map<Identifier, Identifier>;
22
incompletePhis: IncompletePhi[];
23
};
24
@@ -48,99 +46,80 @@ class SSABuilder {
46
return this.#states.get(this.#current)!;
47
}
48
51
- // This tries to reuse all existing information about the oldPlace in case there's
52
- // useful information from previous compiler passes.
53
- makePlace(oldPlace: Place): Place {
54
- const identifier = {
55
- ...oldPlace.identifier,
56
- id: this.nextIdentifierId,
57
- };
49
+ definePlace(oldPlace: Place): Place {
50
+ const oldId = oldPlace.identifier;
51
+ const newId = { ...oldId, id: this.nextIdentifierId };
52
+ this.state().defs.set(oldId, newId);
53
return {
54
...oldPlace,
60
- identifier,
55
+ identifier: newId,
56
};
57
}
58
64
- makePlaceForPhi(oldPlace: Place): Place {
65
- const identifier = {
66
- ...oldPlace.identifier,
67
- id: this.nextIdentifierId,
68
- };
59
+ getPlace(oldPlace: Place): Place {
60
+ const newId = this.getIdAt(oldPlace.identifier, this.#current!);
61
return {
70
- identifier,
71
- kind: "Identifier",
72
- memberPath: null,
73
- effect: Effect.Mutate,
74
- path: null as any,
62
+ ...oldPlace,
63
+ identifier: newId,
64
};
65
}
66
78
- definePlace(oldPlace: Place): Place {
79
- const newPlace = this.makePlace(oldPlace);
80
- this.state().defs.set(oldPlace.identifier.id, newPlace);
81
- return newPlace;
82
- }
83
-
84
- getPlace(oldPlace: Place): Place {
85
- return this.getPlaceAt(oldPlace, this.#current!);
86
- }
87
-
88
- getPlaceAt(oldPlace: Place, block: BasicBlock): Place {
67
+ getIdAt(oldId: Identifier, block: BasicBlock): Identifier {
68
// check if Place is defined locally
69
const state = this.#states.get(block)!;
70
92
- if (state.defs.has(oldPlace.identifier.id)) {
93
- return state.defs.get(oldPlace.identifier.id)!;
71
+ if (state.defs.has(oldId)) {
72
+ return state.defs.get(oldId)!;
73
}
74
75
if (block.preds.size == 0) {
76
// We're at the entry block and haven't found our defintion yet.
77
console.log(
99
- `Unable to find "${printPlace(oldPlace)}", assuming it's a global`
78
+ `Unable to find "${printIdentifier(oldId)}", assuming it's a global`
79
);
101
- //return oldPlace;
80
+ return oldId;
81
}
82
83
if (unsealedPreds.get(block)! > 0) {
84
// We haven't visited all our predecessors, let's place an incomplete phi
85
// for now.
107
- const newPlace = this.makePlaceForPhi(oldPlace);
108
- state.incompletePhis.push({ old: oldPlace, new: newPlace });
109
- state.defs.set(oldPlace.identifier.id, newPlace);
110
- return newPlace;
86
+ const newId = { ...oldId, id: this.nextIdentifierId };
87
+ state.incompletePhis.push({ oldId, newId });
88
+ state.defs.set(oldId, newId);
89
+ return newId;
90
}
91
92
// Only one predecessor, let's check there
93
if (block.preds.size == 1) {
94
const [pred] = block.preds;
116
- const newPlace = this.getPlaceAt(oldPlace, pred);
117
- state.defs.set(oldPlace.identifier.id, newPlace);
118
- return newPlace;
95
+ const newId = this.getIdAt(oldId, pred);
96
+ state.defs.set(oldId, newId);
97
+ return newId;
98
}
99
100
// There are multiple predecessors, we need a phi.
122
- const newPlace = this.makePlaceForPhi(oldPlace);
101
+ const newId = { ...oldId, id: this.nextIdentifierId };
102
// Adding a phi may loop back to our block if there is a loop in the CFG. We
103
// update our defs before adding the phi to terminate the recursion rather than
104
// looping infinitely.
126
- state.defs.set(oldPlace.identifier.id, newPlace);
127
- this.addPhi(block, oldPlace, newPlace);
105
+ state.defs.set(oldId, newId);
106
+ this.addPhi(block, oldId, newId);
107
108
// TODO(gsn): Can we just return `newPlace` rather than looking it up?
109
// `addPhi` _can_ mutate it, but _will_ it?
131
- return state.defs.get(oldPlace.identifier.id)!;
110
+ return state.defs.get(oldId)!;
111
}
112
134
- addPhi(block: BasicBlock, oldPlace: Place, newPlace: Place) {
135
- const predDefs: Map<BasicBlock, Place> = new Map();
113
+ addPhi(block: BasicBlock, oldId: Identifier, newId: Identifier) {
114
+ const predDefs: Map<BasicBlock, Identifier> = new Map();
115
for (const predBlock of block.preds) {
137
- const predPlace = this.getPlaceAt(oldPlace, predBlock);
138
- predDefs.set(predBlock, predPlace);
116
+ const predId = this.getIdAt(oldId, predBlock);
117
+ predDefs.set(predBlock, predId);
118
}
119
120
const phi: Phi = {
121
kind: "Phi",
143
- lvalue: { place: newPlace, kind: InstructionKind.Const },
122
+ id: newId,
123
operands: predDefs,
124
};
125
@@ -150,7 +129,7 @@ class SSABuilder {
129
fixIncompletePhis(block: BasicBlock) {
130
const state = this.#states.get(block)!;
131
for (const phi of state.incompletePhis) {
153
- this.addPhi(block, phi.old, phi.new);
132
+ this.addPhi(block, phi.oldId, phi.newId);
133
}
134
}
135
@@ -166,14 +145,12 @@ class SSABuilder {
145
const text = [];
146
for (const [block, state] of this.#states) {
147
text.push(`bb${block.id}:`);
169
- for (const [id, place] of state.defs) {
170
- text.push(` \$${id} = \$${place.identifier.id}`);
148
+ for (const [oldId, newId] of state.defs) {
149
+ text.push(` \$${oldId}: \$${newId}`);
150
}
151
152
for (const incompletePhi of state.incompletePhis) {
174
- text.push(
175
- ` iphi \$${incompletePhi.new.identifier} = \$${incompletePhi.old.identifier}`
176
- );
153
+ text.push(` iphi \$${incompletePhi.newId} = \$${incompletePhi.oldId}`);
154
}
155
}
156
compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md
+2
-2
@@ -17,8 +17,8 @@ function Component(props) {
17
bb0:
18
Const mutate a$5 = 1
19
Const mutate b$6 = 2
20
- Const mutate x$7 = Array [mutate a$5, mutate b$6]
21
- Return mutate x$7
20
+ Const mutate x$7 = Array [read a$5, read b$6]
21
+ Return freeze x$7
22
```
23
24
## Code
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md
+10
-11
@@ -34,16 +34,15 @@ function foo$0() {
34
35
```
36
bb0:
37
- Const mutate foo$11: phi()
37
Const mutate a$9 = Array []
38
Const mutate b$10 = Object { }
40
- Call mutate foo$11(mutate a$9, mutate b$10)
41
- Const mutate $12 = "div"
42
- Let mutate _$13 = JSX <mutate $12 a={mutate a$9} ></mutate $12>
43
- Call mutate foo$11(mutate b$10)
44
- Const mutate $14 = "div"
45
- Const mutate $15 = JSX <mutate $14 a={mutate a$9} b={mutate b$10} ></mutate $14>
46
- Return mutate $15
39
+ Call mutate foo$4(mutate a$9, mutate b$10)
40
+ Const mutate $11 = "div"
41
+ Let mutate _$12 = JSX <read $11 a={freeze a$9} ></read $11>
42
+ Call mutate foo$4(mutate b$10)
43
+ Const mutate $13 = "div"
44
+ Const mutate $14 = JSX <read $13 a={read a$9} b={freeze b$10} ></read $13>
45
+ Return read $14
46
```
47
48
## Code
@@ -52,10 +51,10 @@ bb0:
51
function Component$0(props$1) {
52
const a$9 = [];
53
const b$10 = {};
55
- foo$11(a$9, b$10);
56
- let _$13 = <div a={a$9}></div>;
54
+ foo$4(a$9, b$10);
55
+ let _$12 = <div a={a$9}></div>;
56
58
- foo$11(b$10);
57
+ foo$4(b$10);
58
return <div a={a$9} b={b$10}></div>;
59
}
60
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md
+8
-8
@@ -24,27 +24,27 @@ bb0:
24
Let mutate x$7 = 1
25
Let mutate y$8 = 2
26
Const mutate $9 = 2
27
- Const mutate $10 = Binary mutate y$8 === mutate $9
28
- If (mutate $10) then:bb2 else:bb1
27
+ 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$18 = 3
32
Goto bb1
33
bb1:
34
predecessor blocks: bb0 bb2
35
- Const mutate y$12: phi(bb0: mutate y$8, bb2: mutate y$8)
36
- Const mutate x$17: phi(bb0: mutate x$7, bb2: mutate x$18)
35
+ y$12: phi(bb0: y$8, bb2: y$8)
36
+ x$17: phi(bb0: x$7, bb2: x$18)
37
Const mutate $11 = 3
38
- Const mutate $13 = Binary mutate y$12 === mutate $11
39
- If (mutate $13) then:bb4 else:bb3
38
+ Const mutate $13 = Binary read y$12 === read $11
39
+ If (read $13) then:bb4 else:bb3
40
bb4:
41
predecessor blocks: bb1
42
Reassign mutate x$16 = 5
43
Goto bb3
44
bb3:
45
predecessor blocks: bb1 bb4
46
- Const mutate x$14: phi(bb1: mutate x$17, bb4: mutate x$16)
47
- Reassign mutate y$15 = mutate x$14
46
+ x$14: phi(bb1: x$17, bb4: x$16)
47
+ Reassign mutate y$15 = read x$14
48
Return
49
```
50
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md
+4
-4
@@ -21,16 +21,16 @@ bb0:
21
Let mutate x$5 = 1
22
Let mutate y$6 = 2
23
Const mutate $7 = 2
24
- Const mutate $8 = Binary mutate y$6 === mutate $7
25
- If (mutate $8) then:bb2 else:bb1
24
+ 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$11 = 3
29
Goto bb1
30
bb1:
31
predecessor blocks: bb0 bb2
32
- Const mutate x$9: phi(bb0: mutate x$5, bb2: mutate x$11)
33
- Reassign mutate y$10 = mutate x$9
32
+ x$9: phi(bb0: x$5, bb2: x$11)
33
+ Reassign mutate y$10 = read x$9
34
Return
35
```
36
compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md
+5
-5
@@ -20,18 +20,18 @@ bb0:
20
Goto bb1
21
bb1:
22
predecessor blocks: bb0 bb4
23
- Const mutate x$7: phi(bb0: mutate x$5, bb4: mutate x$10)
23
+ x$7: phi(bb0: x$5, bb4: x$10)
24
Const mutate $6 = 10
25
- Const mutate $8 = Binary mutate x$7 < mutate $6
26
- If (mutate $8) then:bb4 else:bb2
25
+ 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 mutate x$7 + mutate $9
30
+ Reassign mutate x$10 = Binary read x$7 + read $9
31
Goto bb1
32
bb2:
33
predecessor blocks: bb1
34
- Return mutate x$7
34
+ Return read x$7
35
```
36
37
## Code
compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md
+3
-3
@@ -21,14 +21,14 @@ function foo() {
21
bb0:
22
Let mutate x$5 = 1
23
Let mutate y$6 = 2
24
- If (mutate y$6) then:bb2 else:bb3
24
+ If (read y$6) then:bb2 else:bb3
25
bb2:
26
predecessor blocks: bb0
27
- Let mutate z$8 = Binary mutate x$5 + mutate y$6
27
+ Let mutate z$8 = Binary read x$5 + read y$6
28
Goto bb1
29
bb3:
30
predecessor blocks: bb0
31
- Let mutate z$7 = mutate x$5
31
+ Let mutate z$7 = read x$5
32
Goto bb1
33
bb1:
34
predecessor blocks: bb3 bb2
compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md
+4
-5
@@ -32,11 +32,10 @@ function Foo$0() {
32
33
```
34
bb0:
35
- Const mutate Foo$8: phi()
35
Const mutate a$6 = Array []
36
Const mutate b$7 = Object { }
38
- Let mutate c$9 = New mutate Foo$8(mutate a$6, mutate b$7)
39
- Return mutate c$9
37
+ Let mutate c$8 = New mutate Foo$5(mutate a$6, mutate b$7)
38
+ Return freeze c$8
39
```
40
41
## Code
@@ -45,8 +44,8 @@ bb0:
44
function Component$0(props$1) {
45
const a$6 = [];
46
const b$7 = {};
48
- let c$9 = new Foo$8(a$6, b$7);
49
- return c$9;
47
+ let c$8 = new Foo$5(a$6, b$7);
48
+ return c$8;
49
}
50
51
```
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md
+6
-6
@@ -25,8 +25,8 @@ bb0:
25
Let mutate x$6 = 1
26
Let mutate y$7 = 2
27
Const mutate $8 = 1
28
- Const mutate $9 = Binary mutate x$6 > mutate $8
29
- If (mutate $9) then:bb2 else:bb3
28
+ 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$14 = 2
@@ -37,10 +37,10 @@ bb3:
37
Goto bb1
38
bb1:
39
predecessor blocks: bb3 bb2
40
- Const mutate x$11: phi(bb3: mutate x$6, bb2: mutate x$14)
41
- Const mutate y$12: phi(bb3: mutate y$10, bb2: mutate y$7)
42
- Let mutate t$13 = Object { x: mutate x$11, y: mutate y$12 }
43
- Return mutate t$13
40
+ x$11: phi(bb3: x$6, bb2: x$14)
41
+ y$12: phi(bb3: y$10, bb2: y$7)
42
+ Let mutate t$13 = Object { x: read x$11, y: read y$12 }
43
+ Return freeze t$13
44
```
45
46
## Code
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md
+2
-2
@@ -17,8 +17,8 @@ function Component(props) {
17
bb0:
18
Const mutate a$5 = 1
19
Const mutate b$6 = 2
20
- Const mutate x$7 = Object { a: mutate a$5, b: mutate b$6 }
21
- Return mutate x$7
20
+ Const mutate x$7 = Object { a: read a$5, b: read b$6 }
21
+ Return freeze x$7
22
```
23
24
## Code
compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md
new
+38
@@ -0,0 +1,38 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+function foo() {
6
+ const x = [];
7
+ const y = { x: x };
8
+ y.x.push([]);
9
+ return y;
10
+}
11
+
12
+```
13
+
14
+## HIR
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)
22
+ Return freeze y$5
23
+```
24
+
25
+## Code
26
+
27
+```javascript
28
+function foo$0() {
29
+ const x$4 = [];
30
+ const y$5 = {
31
+ x: x$4,
32
+ };
33
+ y$5.x.push([]);
34
+ return y$5;
35
+}
36
+
37
+```
38
+
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.js
new
+6
@@ -0,0 +1,6 @@
1
+function foo() {
2
+ const x = [];
3
+ const y = { x: x };
4
+ y.x.push([]);
5
+ return y;
6
+}
compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md
new
+35
@@ -0,0 +1,35 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+function foo() {
6
+ const x = [];
7
+ const y = {};
8
+ y.x = x;
9
+ return y;
10
+}
11
+
12
+```
13
+
14
+## HIR
15
+
16
+```
17
+bb0:
18
+ Const mutate x$3 = Array []
19
+ Const mutate y$4 = Object { }
20
+ Reassign mutate y$5.x = read x$3
21
+ Return freeze y$5
22
+```
23
+
24
+## Code
25
+
26
+```javascript
27
+function foo$0() {
28
+ const x$3 = [];
29
+ const y$4 = {};
30
+ y$5 = x$3;
31
+ return y$5;
32
+}
33
+
34
+```
35
+
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/ssa-property.js
new
+6
@@ -0,0 +1,6 @@
1
+function foo() {
2
+ const x = [];
3
+ const y = {};
4
+ y.x = x;
5
+ return y;
6
+}
compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md
+4
-4
@@ -19,16 +19,16 @@ function foo() {
19
bb0:
20
Let mutate x$4 = 1
21
Const mutate $5 = 1
22
- Const mutate $6 = Binary mutate x$4 === mutate $5
23
- If (mutate $6) then:bb2 else:bb1
22
+ 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$8 = 2
27
Goto bb1
28
bb1:
29
predecessor blocks: bb0 bb2
30
- Const mutate x$7: phi(bb0: mutate x$4, bb2: mutate x$8)
31
- Return mutate x$7
30
+ x$7: phi(bb0: x$4, bb2: x$8)
31
+ Return read x$7
32
```
33
34
## Code
compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md
+4
-4
@@ -22,8 +22,8 @@ function foo() {
22
bb0:
23
Let mutate y$5 = 2
24
Const mutate $6 = 1
25
- Const mutate $7 = Binary mutate y$5 > mutate $6
26
- If (mutate $7) then:bb2 else:bb3
25
+ 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$11 = 1
@@ -34,8 +34,8 @@ bb3:
34
Goto bb1
35
bb1:
36
predecessor blocks: bb3 bb2
37
- Const mutate y$9: phi(bb3: mutate y$8, bb2: mutate y$11)
38
- Let mutate x$10 = mutate y$9
37
+ y$9: phi(bb3: y$8, bb2: y$11)
38
+ Let mutate x$10 = read y$9
39
Return
40
```
41
compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md
+2
-2
@@ -19,10 +19,10 @@ function foo() {
19
bb0:
20
Let mutate x$4 = 1
21
Let mutate y$5 = 2
22
- If (mutate y$5) then:bb2 else:bb1
22
+ If (read y$5) then:bb2 else:bb1
23
bb2:
24
predecessor blocks: bb0
25
- Let mutate z$6 = Binary mutate x$4 + mutate y$5
25
+ 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
+10
-10
@@ -30,32 +30,32 @@ function foo() {
30
bb0:
31
Let mutate x$10 = 1
32
Const mutate $11 = 2
33
- Const mutate $12 = Binary mutate x$10 === mutate $11
33
+ Const mutate $12 = Binary read x$10 === read $11
34
Const mutate $13 = 1
35
- Const mutate $14 = Binary mutate x$10 === mutate $13
36
- Switch (mutate x$10)
37
- Case mutate $14: bb5
38
- Case mutate $12: bb3
35
+ 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 $21 = 1
43
- Reassign mutate x$22 = Binary mutate x$10 + mutate $21
43
+ Reassign mutate x$22 = Binary read x$10 + read $21
44
Goto bb1
45
bb3:
46
predecessor blocks: bb0
47
Const mutate $19 = 2
48
- Reassign mutate x$20 = Binary mutate x$10 + mutate $19
48
+ Reassign mutate x$20 = Binary read x$10 + read $19
49
Goto bb1
50
bb2:
51
predecessor blocks: bb0
52
Const mutate $15 = 3
53
- Reassign mutate x$16 = Binary mutate x$10 + mutate $15
53
+ Reassign mutate x$16 = Binary read x$10 + read $15
54
Goto bb1
55
bb1:
56
predecessor blocks: bb5 bb3 bb2
57
- Const mutate x$17: phi(bb5: mutate x$22, bb3: mutate x$20, bb2: mutate x$16)
58
- Let mutate y$18 = mutate x$17
57
+ x$17: phi(bb5: x$22, bb3: x$20, bb2: x$16)
58
+ Let mutate y$18 = read x$17
59
Return
60
```
61
compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md
+4
-4
@@ -18,16 +18,16 @@ function foo() {
18
bb0:
19
Let mutate x$4 = 1
20
Const mutate $5 = 1
21
- Const mutate $6 = Binary mutate x$4 === mutate $5
22
- If (mutate $6) then:bb2 else:bb1
21
+ 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$8 = 2
26
Goto bb1
27
bb1:
28
predecessor blocks: bb0 bb2
29
- Const mutate x$7: phi(bb0: mutate x$4, bb2: mutate x$8)
30
- Throw mutate x$7
29
+ x$7: phi(bb0: x$4, bb2: x$8)
30
+ Throw read x$7
31
```
32
33
## Code
compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md
+5
-5
@@ -21,18 +21,18 @@ bb0:
21
Goto bb1
22
bb1:
23
predecessor blocks: bb0 bb3
24
- Const mutate x$7: phi(bb0: mutate x$5, bb3: mutate x$10)
24
+ x$7: phi(bb0: x$5, bb3: x$10)
25
Const mutate $6 = 10
26
- Const mutate $8 = Binary mutate x$7 < mutate $6
27
- If (mutate $8) then:bb3 else:bb2
26
+ 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 mutate x$7 + mutate $9
31
+ Reassign mutate x$10 = Binary read x$7 + read $9
32
Goto bb1
33
bb2:
34
predecessor blocks: bb1
35
- Return mutate x$7
35
+ Return read x$7
36
```
37
38
## Code