cranelift_codegen::souper_harvest: Move preopt out of Context, into clif-util

This allows for more flexibility of when/where to harvest LHS candidates. For
example, we could choose to harvest candidates that overlap with and supercede
our current preopt peepholes.

This commit also makes sure that we compute the CFG before running preopt, when
harvesting LHS candidates via `clif-util souper-harvest`.
This commit is contained in:
Nick Fitzgerald
2020-09-14 08:46:34 -07:00
parent c87aaeeece
commit e1c8878b33
2 changed files with 5 additions and 3 deletions

View File

@@ -457,10 +457,8 @@ impl Context {
#[cfg(feature = "souper-harvest")]
pub fn souper_harvest(
&mut self,
isa: &dyn TargetIsa,
out: &mut std::sync::mpsc::Sender<String>,
) -> CodegenResult<()> {
self.preopt(isa)?;
do_souper_harvest(&self.func, out);
Ok(())
}

View File

@@ -71,7 +71,11 @@ pub fn run(target: &str, input: &str, output: &str, flag_set: &[String]) -> Resu
let mut ctx = Context::new();
ctx.func = func;
ctx.souper_harvest(fisa.isa.unwrap(), send)
ctx.compute_cfg();
ctx.preopt(fisa.isa.unwrap())
.map_err(|e| format!("failed to run preopt: {}", e))?;
ctx.souper_harvest(send)
.map_err(|e| format!("failed to run souper harvester: {}", e))?;
Ok(())