Skip to content

Commit

Permalink
refactor: remove ValueData::Alias
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat committed Oct 17, 2023
1 parent e0869a2 commit a751d1c
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 296 deletions.
3 changes: 0 additions & 3 deletions codegen/masm/src/stackify/pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2085,9 +2085,6 @@ fn add_data_dependency(
let dep_node = graph.add_node(Node::Stack(value));
graph.add_dependency(node, dep_node);
}
hir::ValueData::Alias { original, .. } => {
add_data_dependency(node, *original, pp, function, graph)
}
}
}

Expand Down
18 changes: 3 additions & 15 deletions frontend-wasm/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,27 +446,18 @@ impl SSABuilder {
sentinel: Value,
dest_block: Block,
) -> Value {
// Determine how many predecessors are yielding unique, non-temporary Values. If a variable
// is live and unmodified across several control-flow join points, earlier blocks will
// introduce aliases for that variable's definition, so we resolve aliases eagerly here to
// ensure that we can tell when the same definition has reached this block via multiple
// paths. Doing so also detects cyclic references to the sentinel, which can occur in
// unreachable code.
// Determine how many predecessors are yielding unique, non-temporary Values.
let num_predecessors = self.predecessors(dest_block).len();
// When this `Drain` is dropped, these elements will get truncated.
let results = self.results.drain(self.results.len() - num_predecessors..);

let pred_val = {
let mut iter = results
.as_slice()
.iter()
.map(|&val| dfg.resolve_aliases(val))
.filter(|&val| val != sentinel);
let mut iter = results.as_slice().iter().filter(|&val| val != &sentinel);
if let Some(val) = iter.next() {
// This variable has at least one non-temporary definition. If they're all the same
// value, we can remove the block parameter and reference that value instead.
if iter.all(|other| other == val) {
Some(val)
Some(*val)
} else {
None
}
Expand All @@ -491,10 +482,7 @@ impl SSABuilder {
if let Some(pred_val) = pred_val {
// Here all the predecessors use a single value to represent our variable
// so we don't need to have it as a block argument.
// We need to replace all the occurrences of val with pred_val but since
// we can't afford a re-writing pass right now we just declare an alias.
dfg.remove_block_param(sentinel);
dfg.change_to_alias(sentinel, pred_val);
pred_val
} else {
// There is disagreement in the predecessors on which value to use so we have
Expand Down
Loading

0 comments on commit a751d1c

Please sign in to comment.