Chaos mode MVP: Skip branch optimization in MachBuffer (#6039)
* fuzz: Add chaos mode control plane Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> * fuzz: Skip branch optimization with chaos mode Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> * fuzz: Rename chaos engine -> control plane Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> * chaos mode: refactoring ControlPlane to be passed through the call stack by reference Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Remo Senekowitsch <contact@remsle.dev> * fuzz: annotate chaos todos Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> * fuzz: cleanup control plane Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> * fuzz: remove control plane from compiler context Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> * fuzz: move control plane into emit state Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> * fuzz: fix remaining compiler errors Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> * fix tests * refactor emission state ctrl plane accessors Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> * centralize conditional compilation of chaos mode Also cleanup a few straggling dependencies on cranelift-control that aren't needed anymore. Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> * add cranelift-control to published crates prtest:full Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> * add cranelift-control to public crates Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> --------- Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com> Co-authored-by: Moritz Waser <mzrw.dev@pm.me> Co-authored-by: Remo Senekowitsch <contact@remsle.dev>
This commit is contained in:
committed by
GitHub
parent
064968b01d
commit
7eb8914090
@@ -33,6 +33,7 @@ use crate::{timing, CompileError};
|
||||
#[cfg(feature = "souper-harvest")]
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use cranelift_control::ControlPlane;
|
||||
|
||||
#[cfg(feature = "souper-harvest")]
|
||||
use crate::souper_harvest::do_souper_harvest;
|
||||
@@ -124,8 +125,9 @@ impl Context {
|
||||
&mut self,
|
||||
isa: &dyn TargetIsa,
|
||||
mem: &mut Vec<u8>,
|
||||
ctrl_plane: &mut ControlPlane,
|
||||
) -> CompileResult<&CompiledCode> {
|
||||
let compiled_code = self.compile(isa)?;
|
||||
let compiled_code = self.compile(isa, ctrl_plane)?;
|
||||
mem.extend_from_slice(compiled_code.code_buffer());
|
||||
Ok(compiled_code)
|
||||
}
|
||||
@@ -133,14 +135,18 @@ impl Context {
|
||||
/// Internally compiles the function into a stencil.
|
||||
///
|
||||
/// Public only for testing and fuzzing purposes.
|
||||
pub fn compile_stencil(&mut self, isa: &dyn TargetIsa) -> CodegenResult<CompiledCodeStencil> {
|
||||
pub fn compile_stencil(
|
||||
&mut self,
|
||||
isa: &dyn TargetIsa,
|
||||
ctrl_plane: &mut ControlPlane,
|
||||
) -> CodegenResult<CompiledCodeStencil> {
|
||||
let _tt = timing::compile();
|
||||
|
||||
self.verify_if(isa)?;
|
||||
|
||||
self.optimize(isa)?;
|
||||
|
||||
isa.compile_function(&self.func, &self.domtree, self.want_disasm)
|
||||
isa.compile_function(&self.func, &self.domtree, self.want_disasm, ctrl_plane)
|
||||
}
|
||||
|
||||
/// Optimize the function, performing all compilation steps up to
|
||||
@@ -212,11 +218,17 @@ impl Context {
|
||||
/// code sink.
|
||||
///
|
||||
/// Returns information about the function's code and read-only data.
|
||||
pub fn compile(&mut self, isa: &dyn TargetIsa) -> CompileResult<&CompiledCode> {
|
||||
let stencil = self.compile_stencil(isa).map_err(|error| CompileError {
|
||||
inner: error,
|
||||
func: &self.func,
|
||||
})?;
|
||||
pub fn compile(
|
||||
&mut self,
|
||||
isa: &dyn TargetIsa,
|
||||
ctrl_plane: &mut ControlPlane,
|
||||
) -> CompileResult<&CompiledCode> {
|
||||
let stencil = self
|
||||
.compile_stencil(isa, ctrl_plane)
|
||||
.map_err(|error| CompileError {
|
||||
inner: error,
|
||||
func: &self.func,
|
||||
})?;
|
||||
Ok(self
|
||||
.compiled_code
|
||||
.insert(stencil.apply_params(&self.func.params)))
|
||||
|
||||
Reference in New Issue
Block a user