Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify control flow for CFGs generated by eggcc. #610

Merged
merged 12 commits into from
May 30, 2024
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
Loading