[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.
This commit is contained in:
Sathya Gunasekaran
2022-12-21 21:13:57 +00:00
parent 8c920cfa90
commit b59f9dd561
+2 -47
View File
@@ -5,55 +5,13 @@ export type AliasSet = Set<Identifier>;
class AliasAnalyser {
aliases = new DisjointSet<Identifier>();
// NOTE(gsn): Should this be a part of AbstractObject? No, because this has
// nothing to do with values in the object.
objectAliases = new Map<Identifier, Map<string, AliasSet>>();
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<string, AliasSet>();
this.objectAliases.set(lvalue.place.identifier, objectAlias);
}
let memberAlias = objectAlias.get(memberPath);
if (memberAlias === undefined) {
memberAlias = new Set<Identifier>();
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);
}