[hir] Treat values escaping into a contextref as Mutate

This commit is contained in:
Sathya Gunasekaran
2023-03-03 13:35:02 +00:00
parent f002682322
commit f17f4dcf0b
@@ -783,8 +783,12 @@ function inferBlock(
continue;
}
case "LoadLocal": {
state.reference(instrValue.place, Effect.Capture);
const lvalue = instr.lvalue;
const effect =
state.isDefined(lvalue) && state.kind(lvalue) === ValueKind.Context
? Effect.Mutate
: Effect.Capture;
state.reference(instrValue.place, effect);
lvalue.effect = Effect.Mutate;
// direct aliasing: `a = b`;
state.alias(lvalue, instrValue.place);