From b59f9dd5618ac21e45a93e89df462a484519efab Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Wed, 21 Dec 2022 21:13:57 +0000 Subject: [PATCH] [hir] Remove unused code from InferAlias For now, we've decided to punt on super fine grained aliasing of fields (ie, mutating x.y shouldn't mutate x.z or it's aliases). This PR removes the code that tracks the aliases of each field. We can re-add this when we revisit this functionality. For the rest of the field aliasing, most of it has been replaced by InferAliasForStores. --- compiler/forget/src/HIR/InferAlias.ts | 49 ++------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) 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); }