@samitouri / QOS-React-2 / commits / bae2cb5f89

Remove now-unnecessary mutable range extension in LeaveSSA

This is no longer necessary now that we extend phi operands' ranges in InferMutableRanges

Joe Savona committed Feb 21, 2023 at 15:29 UTC bae2cb5f89790eb6693e2f56ae24dcbabb3316f1
1 file changed +7 -6
compiler/forget/src/SSA/LeaveSSA.ts
+7 -6
@@ -260,14 +260,15 @@ export function leaveSSA(fn: HIRFunction): void {
260 phi.id.mutableRange.end = makeInstructionId(terminal.id + 1);
261 }
262 } else if (isPhiMutatedAfterCreation) {
263 + // The declaration is not guaranteed to flow into the phi, for example in the case of a variable
264 + // that is reassigned in all control flow paths to a given phi. The original declaration's range
265 + // has to be extended in this case (if the phi is later mutated) since we are reusing the original
266 + // declaration instead of creating a new declaration.
267 + //
268 + // NOTE: this can *only* happen if the original declaration involves an instruction that DCE does
269 + // not prune. Otherwise, the declaration would have been pruned and we'd synthesize a new one.
270 declaration.place.identifier.mutableRange.end = phi.id.mutableRange.end;
271 }
265 -
266 - for (const [, operand] of phi.operands) {
267 - if (isPhiMutatedAfterCreation) {
268 - operand.mutableRange.end = phi.id.mutableRange.end;
269 - }
270 - }
272 }
273
274 // Similar logic for rewrite phis that occur in loops, except that instead of a new let binding