mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-14 22:38:46 +00:00
Fix: Optimize before visualizing IR
When you do ``` cargo run -- --simplify-cfg --irviz test.png test.c ``` The `kecc` first tries to visualize the IR, then apply optimizations. This should not be intended, as right now there's no way to visualize the IR after optimizations.
This commit is contained in:
40
bin/kecc.rs
40
bin/kecc.rs
@@ -141,6 +141,26 @@ fn compile_ir(
|
||||
return;
|
||||
}
|
||||
|
||||
if matches.optimize {
|
||||
O1::default().optimize(input);
|
||||
} else {
|
||||
if matches.simplify_cfg {
|
||||
SimplifyCfg::default().optimize(input);
|
||||
}
|
||||
|
||||
if matches.mem2reg {
|
||||
Mem2reg::default().optimize(input);
|
||||
}
|
||||
|
||||
if matches.deadcode {
|
||||
Deadcode::default().optimize(input);
|
||||
}
|
||||
|
||||
if matches.gvn {
|
||||
Gvn::default().optimize(input);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(path) = &matches.irviz {
|
||||
assert_eq!(
|
||||
Path::new(&path).extension(),
|
||||
@@ -181,26 +201,6 @@ fn compile_ir(
|
||||
temp_dir.close().expect("temp dir deletion failed");
|
||||
}
|
||||
|
||||
if matches.optimize {
|
||||
O1::default().optimize(input);
|
||||
} else {
|
||||
if matches.simplify_cfg {
|
||||
SimplifyCfg::default().optimize(input);
|
||||
}
|
||||
|
||||
if matches.mem2reg {
|
||||
Mem2reg::default().optimize(input);
|
||||
}
|
||||
|
||||
if matches.deadcode {
|
||||
Deadcode::default().optimize(input);
|
||||
}
|
||||
|
||||
if matches.gvn {
|
||||
Gvn::default().optimize(input);
|
||||
}
|
||||
}
|
||||
|
||||
if matches.iroutput {
|
||||
write(input, output).unwrap();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user