Skip to content

Commit

Permalink
Simplify control flow for CFGs generated by eggcc. (#610)
Browse files Browse the repository at this point in the history
Add a new branch simplification pass to reduce overhead introduced by RVSDGs
  • Loading branch information
ezrosent committed May 30, 2024
1 parent 698bac1 commit 516a106
Show file tree
Hide file tree
Showing 18 changed files with 788 additions and 105 deletions.
94 changes: 47 additions & 47 deletions 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.1.0"
bril-rs = { git = "https://github.com/uwplse/bril", rev = "78881c45aa53231915f333d1d6dcc26cedc63b57" }
bril-rs = { git = "https://github.com/uwplse/bril", rev = "e2be3f5" }
indexmap = "2.0.0"
rustc-hash = "1.1.0"
ordered-float = "3"
Expand Down
2 changes: 1 addition & 1 deletion dag_in_context/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.74.0
1.78.0
3 changes: 2 additions & 1 deletion dag_in_context/src/typechecker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ impl Expr {
);
new_expr
}

/// Adds argument types to the expression.
#[allow(dead_code)]
pub(crate) fn add_arg_type(self: RcExpr, input_ty: Type) -> RcExpr {
// we need a dummy program, since there are no calls in self
let prog = program!(function("dummy", tuplet!(), tuplet!(), empty()),);
Expand All @@ -73,6 +73,7 @@ impl Expr {
new_expr
}

#[allow(dead_code)]
pub(crate) fn func_with_arg_types(self: RcExpr) -> RcExpr {
match self.as_ref() {
Expr::Function(name, in_ty, out_ty, body) => RcExpr::new(Expr::Function(
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.74.0
1.78.0
1 change: 1 addition & 0 deletions src/rvsdg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub(crate) mod live_variables;
pub(crate) mod optimize_direct_jumps;
pub(crate) mod restructure;
pub(crate) mod rvsdg2svg;
pub(crate) mod simplify_branches;
pub(crate) mod to_cfg;
mod to_dag;

Expand Down
11 changes: 10 additions & 1 deletion src/rvsdg/optimize_direct_jumps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,16 @@ impl SimpleCfgFunction {
impl SimpleCfgProgram {
pub fn optimize_jumps(&self) -> Self {
SimpleCfgProgram {
functions: self.functions.iter().map(|f| f.optimize_jumps()).collect(),
functions: self
.functions
.iter()
.map(|f| {
// NB: We could avoid this copy by having `optimize_jumps` take `self` by value.
let mut res = f.optimize_jumps();
res.simplify_branches();
res
})
.collect(),
}
}
}
Expand Down
Loading

0 comments on commit 516a106

Please sign in to comment.