@samitouri / QOS-React / commits / 89151eb487

[ssa][be] Refactor visitedBlocks out of SSABuilder

Sathya Gunasekaran committed Oct 27, 2022 at 16:43 UTC 89151eb4871a040fea3e8cefd095019f63bc1876
1 file changed +4 -4
compiler/forget/src/HIR/SSAify.ts
+4 -4
@@ -27,7 +27,6 @@ const unsealedPreds: Map<BasicBlock, number> = new Map();
27 class SSABuilder {
28 #states: Map<BasicBlock, State> = new Map();
29 #current: BasicBlock | null = null;
30 - visitedBlocks: Set<BasicBlock> = new Set();
30 #env: Environment;
31
32 constructor(env: Environment) {
@@ -164,13 +163,14 @@ class SSABuilder {
163 }
164
165 export default function buildSSA(func: HIRFunction, env: Environment) {
166 + const visitedBlocks: Set<BasicBlock> = new Set();
167 const builder = new SSABuilder(env);
168 for (const [blockId, block] of func.body.blocks) {
169 invariant(
170 - !builder.visitedBlocks.has(block),
170 + !visitedBlocks.has(block),
171 `found a cycle! visiting bb${block.id} again`
172 );
173 - builder.visitedBlocks.add(block);
173 + visitedBlocks.add(block);
174
175 builder.startBlock(block);
176
@@ -204,7 +204,7 @@ export default function buildSSA(func: HIRFunction, env: Environment) {
204 }
205 unsealedPreds.set(output, count);
206
207 - if (count == 0 && builder.visitedBlocks.has(output)) {
207 + if (count == 0 && visitedBlocks.has(output)) {
208 builder.fixIncompletePhis(output);
209 }
210 }