diff --git a/lib/cretonne/src/context.rs b/lib/cretonne/src/context.rs index f8a207c6fc..e4ba8a0667 100644 --- a/lib/cretonne/src/context.rs +++ b/lib/cretonne/src/context.rs @@ -54,7 +54,7 @@ impl Context { /// The `TargetIsa` argument is currently unused, but the verifier will soon be able to also /// check ISA-dependent constraints. pub fn verify<'a, ISA: Into>>(&self, _isa: ISA) -> verifier::Result { - verifier::verify_context(self) + verifier::verify_context(&self.func, &self.cfg, &self.domtree) } /// Run the verifier only if the `enable_verifier` setting is true. @@ -81,7 +81,6 @@ impl Context { /// Run the register allocator. pub fn regalloc(&mut self, isa: &TargetIsa) -> CtonResult { self.regalloc - .run(isa, &mut self.func, &self.cfg, &self.domtree)?; - self.verify_if(isa) + .run(isa, &mut self.func, &self.cfg, &self.domtree) } } diff --git a/lib/cretonne/src/regalloc/context.rs b/lib/cretonne/src/regalloc/context.rs index 5d91a258fa..8f399c65de 100644 --- a/lib/cretonne/src/regalloc/context.rs +++ b/lib/cretonne/src/regalloc/context.rs @@ -12,7 +12,7 @@ use regalloc::coloring::Coloring; use regalloc::live_value_tracker::LiveValueTracker; use regalloc::liveness::Liveness; use result::CtonResult; -use verifier::verify_liveness; +use verifier::{verify_context, verify_liveness}; /// Persistent memory allocations for register allocation. pub struct Context { @@ -62,6 +62,10 @@ impl Context { self.coloring .run(isa, func, domtree, &mut self.liveness, &mut self.tracker); + if isa.flags().enable_verifier() { + verify_context(func, cfg, domtree)?; + verify_liveness(isa, func, cfg, &self.liveness)?; + } Ok(()) } } diff --git a/lib/cretonne/src/verifier/mod.rs b/lib/cretonne/src/verifier/mod.rs index f2e8a7fc50..1cc8f740dd 100644 --- a/lib/cretonne/src/verifier/mod.rs +++ b/lib/cretonne/src/verifier/mod.rs @@ -58,7 +58,6 @@ use ir::entities::AnyEntity; use ir::instructions::{InstructionFormat, BranchInfo, ResolvedConstraint, CallInfo}; use ir::{types, Function, ValueDef, Ebb, Inst, SigRef, FuncRef, ValueList, JumpTable, StackSlot, Value, Type}; -use Context; use std::error as std_error; use std::fmt::{self, Display, Formatter}; use std::result; @@ -114,11 +113,12 @@ pub fn verify_function(func: &Function) -> Result { Verifier::new(func).run() } -/// Verify `ctx`. -pub fn verify_context(ctx: &Context) -> Result { - let verifier = Verifier::new(&ctx.func); - verifier.domtree_integrity(&ctx.domtree)?; - verifier.cfg_integrity(&ctx.cfg)?; +/// Verify `func` after checking the integrity of associated context data structures `cfg` and +/// `domtree`. +pub fn verify_context(func: &Function, cfg: &ControlFlowGraph, domtree: &DominatorTree) -> Result { + let verifier = Verifier::new(func); + verifier.cfg_integrity(cfg)?; + verifier.domtree_integrity(domtree)?; verifier.run() }