Skip to content

Commit

Permalink
clear block as well
Browse files Browse the repository at this point in the history
  • Loading branch information
oflatt committed Oct 30, 2024
1 parent 162155d commit 013ad4d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 25 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ smallvec = "1.11.1"

syn = { version = "2.0", features = ["full", "extra-traits"] }
# currently using the uwplse/bril fork of bril, on eggcc-main
bril2json = { git = "https://github.com/uwplse/bril", rev = "fe255deec1533960b20fff832971e45810202a5d" }
brilirs = { git = "https://github.com/uwplse/bril", rev = "fe255deec1533960b20fff832971e45810202a5d" }
bril-rs = { git = "https://github.com/uwplse/bril", rev = "fe255deec1533960b20fff832971e45810202a5d" }
brilift = { git = "https://github.com/uwplse/bril", rev = "fe255deec1533960b20fff832971e45810202a5d" }
rs2bril = { git = "https://github.com/uwplse/bril", rev = "fe255deec1533960b20fff832971e45810202a5d" ,features = [
bril2json = { git = "https://github.com/uwplse/bril", rev = "5832cb758964402e8bb3b60b85e2cc36b368e2e7" }
brilirs = { git = "https://github.com/uwplse/bril", rev = "5832cb758964402e8bb3b60b85e2cc36b368e2e7" }
bril-rs = { git = "https://github.com/uwplse/bril", rev = "5832cb758964402e8bb3b60b85e2cc36b368e2e7" }
brilift = { git = "https://github.com/uwplse/bril", rev = "5832cb758964402e8bb3b60b85e2cc36b368e2e7" }
rs2bril = { git = "https://github.com/uwplse/bril", rev = "5832cb758964402e8bb3b60b85e2cc36b368e2e7" ,features = [
"import",
] }
brillvm = { git = "https://github.com/uwplse/bril", rev = "fe255deec1533960b20fff832971e45810202a5d" }
brillvm = { git = "https://github.com/uwplse/bril", rev = "5832cb758964402e8bb3b60b85e2cc36b368e2e7" }


ordered-float = { version = "3.7" }
Expand Down
2 changes: 1 addition & 1 deletion dag_in_context/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dag_in_context/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ strum_macros = "0.25"
main_error = "0.1.2"
thiserror = "1.0"
egraph-serialize = "0.2.0"
bril-rs = { git = "https://github.com/uwplse/bril", rev = "fe255deec1533960b20fff832971e45810202a5d" }
bril-rs = { git = "https://github.com/uwplse/bril", rev = "5832cb758964402e8bb3b60b85e2cc36b368e2e7" }
indexmap = "2.0.0"
rustc-hash = "1.1.0"
ordered-float = "3"
Expand Down
19 changes: 14 additions & 5 deletions src/rvsdg/optimize_direct_jumps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ impl SimpleCfgFunction {
}

/// Find blocks that return and fuze them with parent blocks that jump unconditionaly to them.
/// All parents must jump unconditionally to the block.
fn return_early(mut self) -> SimpleCfgFunction {
// for each node
for node in self.graph.node_indices().collect::<Vec<_>>() {
Expand All @@ -101,8 +102,17 @@ impl SimpleCfgFunction {
.map(|edge| edge.source())
.collect::<Vec<_>>();

// if the node contains a return
if self.has_return(node) {
// if the node contains a return, and all parents jump unconditionally to this node
// and more than one parent
if self.has_return(node)
&& parents.iter().all(|parent| {
self.graph
.edges_directed(*parent, Direction::Outgoing)
.count()
== 1
})
&& !parents.is_empty()
{
// for each parent, fuze up
for parent in &parents {
// if the parent doesn't contain return instructions
Expand All @@ -116,16 +126,15 @@ impl SimpleCfgFunction {
{
let instrs = self.graph[node].instrs.clone();
let footer = self.graph[node].footer.clone();
eprintln!("Add instructions {:?} to parent {:?}", instrs, parent);
eprintln!("Add footer {:?} to parent {:?}", footer, parent);
eprintln!("Parent has instrs {:?}", self.graph[*parent].instrs);
// move instructions from node up to parent
self.graph[*parent].instrs.extend(instrs);
// move footer up to parent
self.graph[*parent].footer.extend(footer);
};
}
}
// clear the instructions in this node
self.graph[node].instrs.clear();
}
}

Expand Down

0 comments on commit 013ad4d

Please sign in to comment.