diff --git a/libs/@local/hashql/compiletest/src/pipeline.rs b/libs/@local/hashql/compiletest/src/pipeline.rs index 8b18e299072..e347acb4e28 100644 --- a/libs/@local/hashql/compiletest/src/pipeline.rs +++ b/libs/@local/hashql/compiletest/src/pipeline.rs @@ -31,12 +31,7 @@ use hashql_mir::{ body::Body, context::MirContext, def::{DefId, DefIdSlice, DefIdVec}, - pass::{ - Changed, GlobalAnalysisPass as _, GlobalTransformPass as _, GlobalTransformState, - analysis::SizeEstimationAnalysis, - execution::{ExecutionAnalysis, ExecutionAnalysisResidual}, - transform::{Inline, InlineConfig, PostInline, PreInline}, - }, + pass::{self, LowerConfig, execution::ExecutionAnalysisResidual}, reify::ReifyContext, }; use hashql_syntax_jexpr::span::Span; @@ -189,9 +184,11 @@ impl<'heap> Pipeline<'heap> { bodies: &mut bodies, mir: &mut mir_context, hir: &hir_context, + scratch: &self.scratch, }; let entry = tri!(hashql_mir::reify::from_hir(node, &mut reify_context)); + self.scratch.reset(); // drain the context, because we're going to re-create it self.diagnostics.extend( @@ -218,24 +215,14 @@ impl<'heap> Pipeline<'heap> { bodies: &mut DefIdSlice
>, ) -> Result<(), BoxedDiagnostic<'static, SpanId>> { let mut context = MirContext::new(&self.env, interner); - let mut state = GlobalTransformState::new_in(&*bodies, self.heap); - - self.scratch.reset(); - - let mut pass = PreInline::new_in(&mut self.scratch); - let _: Changed = pass.run(&mut context, &mut state, bodies); - self.scratch.reset(); - - let mut pass = Inline::new_in(InlineConfig::default(), &mut self.scratch); - let _: Changed = pass.run(&mut context, &mut state, bodies); - self.scratch.reset(); - let mut pass = PostInline::new_in(&mut self.scratch); - let _: Changed = pass.run(&mut context, &mut state, bodies); - self.scratch.reset(); - - let status = context.diagnostics.generalize().boxed().into_status(()); - process_status(&mut self.diagnostics, status)?; + let result = pass::lower( + &mut context, + &mut self.scratch, + bodies, + &LowerConfig::default(), + ); + process_status(&mut self.diagnostics, result)?; Ok(()) } @@ -262,20 +249,8 @@ impl<'heap> Pipeline<'heap> { > { let mut context = MirContext::new(&self.env, interner); - let mut pass = SizeEstimationAnalysis::new_in(&self.scratch); - pass.run(&mut context, bodies); - let footprints = pass.finish(); - self.scratch.reset(); - - let pass = ExecutionAnalysis { - footprints: &footprints, - scratch: &mut self.scratch, - }; - let analysis = pass.run_all_in(&mut context, bodies, self.heap); - self.scratch.reset(); - - let status = context.diagnostics.generalize().boxed().into_status(()); - process_status(&mut self.diagnostics, status)?; + let status = pass::place(&mut context, &mut self.scratch, bodies); + let analysis = process_status(&mut self.diagnostics, status)?; Ok(analysis) } diff --git a/libs/@local/hashql/compiletest/src/suite/eval_postgres.rs b/libs/@local/hashql/compiletest/src/suite/eval_postgres.rs index 721796be1e9..7cd0bd37246 100644 --- a/libs/@local/hashql/compiletest/src/suite/eval_postgres.rs +++ b/libs/@local/hashql/compiletest/src/suite/eval_postgres.rs @@ -122,7 +122,7 @@ impl Suite for EvalPostgres { &interner, &bodies, &analysis, - context.heap, + heap, &mut scratch, ); scratch.reset(); diff --git a/libs/@local/hashql/compiletest/src/suite/mir_pass_analysis_data_dependency.rs b/libs/@local/hashql/compiletest/src/suite/mir_pass_analysis_data_dependency.rs index d249c5cbc15..8d10d49f139 100644 --- a/libs/@local/hashql/compiletest/src/suite/mir_pass_analysis_data_dependency.rs +++ b/libs/@local/hashql/compiletest/src/suite/mir_pass_analysis_data_dependency.rs @@ -38,7 +38,8 @@ impl Suite for MirPassAnalysisDataDependency { let mut buffer = Vec::new(); - let (root, mut bodies) = mir_reify(heap, expr, &interner, &mut environment, diagnostics)?; + let (root, mut bodies, _) = + mir_reify(heap, expr, &interner, &mut environment, diagnostics)?; writeln!(buffer, "{}\n", Header::new("MIR")).expect("should be able to write to buffer"); mir_format_text(heap, &environment, &mut buffer, root, &bodies); diff --git a/libs/@local/hashql/compiletest/src/suite/mir_pass_transform_cfg_simplify.rs b/libs/@local/hashql/compiletest/src/suite/mir_pass_transform_cfg_simplify.rs index fa54cc8f4f7..a4e19a5d7cf 100644 --- a/libs/@local/hashql/compiletest/src/suite/mir_pass_transform_cfg_simplify.rs +++ b/libs/@local/hashql/compiletest/src/suite/mir_pass_transform_cfg_simplify.rs @@ -49,7 +49,8 @@ pub(crate) fn mir_pass_transform_cfg_simplify<'heap>( environment: &mut Environment<'heap>, diagnostics: &mut Vec