[be] Tidy up some mutableRange logic

This commit is contained in:
Joe Savona
2023-02-13 15:26:07 -08:00
parent 225fe0835c
commit 5673588be4
2 changed files with 3 additions and 12 deletions
@@ -102,14 +102,14 @@ export function inferMutableLifetimes(
for (const [_, block] of func.body.blocks) {
for (const phi of block.phis) {
let start = Number.MAX_SAFE_INTEGER;
let end = Number.MIN_SAFE_INTEGER;
let end = phi.id.mutableRange.end as number;
for (const [_, operand] of phi.operands) {
start = Math.min(start, operand.mutableRange.start);
end = Math.max(end, operand.mutableRange.end);
}
invariant(
start !== Number.MAX_SAFE_INTEGER && end !== Number.MIN_SAFE_INTEGER,
"Expected phi to have set start/end range values"
start !== Number.MAX_SAFE_INTEGER,
"Expected phi to have a start range value"
);
phi.id.mutableRange = {
start: makeInstructionId(start),
@@ -148,15 +148,6 @@ export function inferReactiveScopeVariables(fn: HIRFunction): void {
}
vars.add(identifier);
});
// Copy scope ranges to identifier ranges: not strictly required but this is useful
// for visualization
for (const [scope, vars] of scopeVariables) {
for (const identifier of vars) {
identifier.mutableRange.start = scope.range.start;
identifier.mutableRange.end = scope.range.end;
}
}
}
// Is the operand mutable at this given instruction