Skip to content

Commit

Permalink
remove mention of footers now that we remove them
Browse files Browse the repository at this point in the history
  • Loading branch information
oflatt committed Oct 30, 2024
1 parent 59f285c commit ea43a2a
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/rvsdg/optimize_direct_jumps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,8 @@ impl SimpleCfgFunction {
== 1
{
let instrs = self.graph[node].instrs.clone();
let footer = self.graph[node].footer.clone();
// move instructions from node up to parent
self.graph[*parent].instrs.extend(instrs);
// move footer up to parent
self.graph[*parent].footer.extend(footer);
};
}
}
Expand Down Expand Up @@ -160,7 +157,6 @@ impl SimpleCfgFunction {

// check if fusing up is possible- instructions are all id
// and parents directly jump to this block
// and the footer is empty.
// Also needs at least one parent
let should_apply = self.graph[node].instrs.iter().all(|instr| {
matches!(
Expand All @@ -176,16 +172,13 @@ impl SimpleCfgFunction {
.edges_directed(*parent, Direction::Outgoing)
.count();
parent_outgoing == 1
}) && self.graph[node].footer.is_empty()
&& !parents.is_empty();
}) && !parents.is_empty();

let new_instrs = self.graph[node].instrs.clone();
// move instructions from node up to parents
if should_apply {
for parent in parents {
if self.graph[parent].footer.is_empty() {
self.graph[parent].instrs.extend(new_instrs.clone());
}
self.graph[parent].instrs.extend(new_instrs.clone());
}

// delete instructions from node
Expand Down Expand Up @@ -246,12 +239,9 @@ impl SimpleCfgFunction {

// add instructions to the beginning of the next node
let mut new_instrs = self.graph[node].instrs.to_vec();
let mut new_footer = self.graph[node].footer.to_vec();
new_instrs.extend(resulting_graph[new_target].instrs.to_vec());
new_footer.extend(resulting_graph[new_target].footer.to_vec());

resulting_graph[new_target].instrs = new_instrs;
resulting_graph[new_target].footer = new_footer;
} else {
// add the node
let new_node = resulting_graph.add_node(self.graph[node].clone());
Expand Down Expand Up @@ -284,7 +274,7 @@ impl SimpleCfgFunction {
let mut to_remove = vec![];
for node in self.graph.node_indices().collect::<Vec<_>>() {
// empty block with a single direct jump out
if self.graph[node].instrs.is_empty() && self.graph[node].footer.is_empty() {
if self.graph[node].instrs.is_empty() {
if let [single_child] = self
.graph
.edges_directed(node, Direction::Outgoing)
Expand Down

0 comments on commit ea43a2a

Please sign in to comment.