diff --git a/compiler/forget/src/HIR/InferAlias.ts b/compiler/forget/src/HIR/InferAlias.ts index 001169f737..b42cb60789 100644 --- a/compiler/forget/src/HIR/InferAlias.ts +++ b/compiler/forget/src/HIR/InferAlias.ts @@ -5,55 +5,13 @@ export type AliasSet = Set; class AliasAnalyser { aliases = new DisjointSet(); - // NOTE(gsn): Should this be a part of AbstractObject? No, because this has - // nothing to do with values in the object. - objectAliases = new Map>(); alias(lvalue: LValue, alias: Place) { - // Complex lvalue: - // lvalue.memberPath = alias; - // lvalue.memberPath = alias.someMemberPath; + // This is handled by InferAliasForStores. if (lvalue.place.memberPath !== null) { - // TODO(gsn): Handle nested memberPaths in lvalue. - if (lvalue.place.memberPath.length > 1) { - return; - } - let memberPath = lvalue.place.memberPath[0]; - - // Consider the case of: - // lvalue.memberPath = alias; - // mutate(lvalue); <-- `alias` should be considered mutable - // here. - // - // Similarly for this case, - // mutate(lvalue.memberPath); <-- `alias` should be considered mutable - // here as well. - // - // But what about this case: - // mutate(lvalue.foo); <-- Do we consider `alias` mutable here? - // No! - // - // To distinguish between these different cases, we need to build separate - // alias sets for each memberPath of `lvalue`. - let objectAlias = this.objectAliases.get(lvalue.place.identifier); - if (objectAlias === undefined) { - objectAlias = new Map(); - this.objectAliases.set(lvalue.place.identifier, objectAlias); - } - - let memberAlias = objectAlias.get(memberPath); - if (memberAlias === undefined) { - memberAlias = new Set(); - objectAlias.set(memberPath, memberAlias); - } - - memberAlias.add(alias.identifier); return; } - // Simple lvalue: - // lvalue = alias; - // lvalue = alias.memberPath; this.aliases.union([lvalue.place.identifier, alias.identifier]); } } @@ -81,12 +39,9 @@ function inferInstr(instr: Instruction, state: AliasAnalyser) { return; } - // TODO(gsn): handle this. if (lvalue === null) { return; } - if (alias !== null) { - state.alias(lvalue, alias); - } + state.alias(lvalue, alias); }