From 89151eb4871a040fea3e8cefd095019f63bc1876 Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Thu, 27 Oct 2022 16:43:41 +0100 Subject: [PATCH] [ssa][be] Refactor visitedBlocks out of SSABuilder --- compiler/forget/src/HIR/SSAify.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/forget/src/HIR/SSAify.ts b/compiler/forget/src/HIR/SSAify.ts index 984ec93d24..885ac5b0aa 100644 --- a/compiler/forget/src/HIR/SSAify.ts +++ b/compiler/forget/src/HIR/SSAify.ts @@ -27,7 +27,6 @@ const unsealedPreds: Map = new Map(); class SSABuilder { #states: Map = new Map(); #current: BasicBlock | null = null; - visitedBlocks: Set = new Set(); #env: Environment; constructor(env: Environment) { @@ -164,13 +163,14 @@ class SSABuilder { } export default function buildSSA(func: HIRFunction, env: Environment) { + const visitedBlocks: Set = new Set(); const builder = new SSABuilder(env); for (const [blockId, block] of func.body.blocks) { invariant( - !builder.visitedBlocks.has(block), + !visitedBlocks.has(block), `found a cycle! visiting bb${block.id} again` ); - builder.visitedBlocks.add(block); + visitedBlocks.add(block); builder.startBlock(block); @@ -204,7 +204,7 @@ export default function buildSSA(func: HIRFunction, env: Environment) { } unsealedPreds.set(output, count); - if (count == 0 && builder.visitedBlocks.has(output)) { + if (count == 0 && visitedBlocks.has(output)) { builder.fixIncompletePhis(output); } }