Merge pull request #1542 from rust-lang/disable_verifier
Disable clif ir verifier by default
This commit is contained in:
commit
0b8e94eb69
4 changed files with 25 additions and 5 deletions
11
src/base.rs
11
src/base.rs
|
|
@ -14,6 +14,7 @@ use rustc_middle::ty::adjustment::PointerCoercion;
|
|||
use rustc_middle::ty::layout::FnAbiOf;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
|
||||
use crate::BackendConfig;
|
||||
use crate::constant::ConstantCx;
|
||||
use crate::debuginfo::{FunctionDebugContext, TypeDebugContext};
|
||||
use crate::inline_asm::codegen_naked_asm;
|
||||
|
|
@ -30,6 +31,7 @@ pub(crate) struct CodegenedFunction {
|
|||
|
||||
pub(crate) fn codegen_fn<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
backend_config: &BackendConfig,
|
||||
cx: &mut crate::CodegenCx,
|
||||
type_dbg: &mut TypeDebugContext<'tcx>,
|
||||
cached_func: Function,
|
||||
|
|
@ -162,7 +164,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
|||
}
|
||||
|
||||
// Verify function
|
||||
verify_func(tcx, &clif_comments, &func);
|
||||
verify_func(tcx, backend_config, &clif_comments, &func);
|
||||
|
||||
Some(CodegenedFunction { symbol_name, func_id, func, clif_comments, func_debug_cx })
|
||||
}
|
||||
|
|
@ -264,11 +266,16 @@ pub(crate) fn compile_fn(
|
|||
});
|
||||
}
|
||||
|
||||
pub(crate) fn verify_func(
|
||||
fn verify_func(
|
||||
tcx: TyCtxt<'_>,
|
||||
backend_config: &BackendConfig,
|
||||
writer: &crate::pretty_clif::CommentWriter,
|
||||
func: &Function,
|
||||
) {
|
||||
if !tcx.sess.verify_llvm_ir() && !backend_config.enable_verifier {
|
||||
return;
|
||||
}
|
||||
|
||||
tcx.prof.generic_activity("verify clif ir").run(|| {
|
||||
let flags = cranelift_codegen::settings::Flags::new(cranelift_codegen::settings::builder());
|
||||
match cranelift_codegen::verify_function(&func, &flags) {
|
||||
|
|
|
|||
|
|
@ -516,6 +516,7 @@ fn module_codegen(
|
|||
MonoItem::Fn(inst) => {
|
||||
if let Some(codegened_function) = crate::base::codegen_fn(
|
||||
tcx,
|
||||
&backend_config,
|
||||
&mut cx,
|
||||
&mut type_dbg,
|
||||
Function::new(),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use crate::{BackendConfig, CodegenCx, CodegenMode};
|
|||
|
||||
struct JitState {
|
||||
jit_module: UnwindModule<JITModule>,
|
||||
backend_config: BackendConfig,
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
|
|
@ -115,6 +116,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
|
|||
CodegenMode::Jit => {
|
||||
codegen_and_compile_fn(
|
||||
tcx,
|
||||
&backend_config,
|
||||
&mut cx,
|
||||
&mut cached_context,
|
||||
&mut jit_module,
|
||||
|
|
@ -169,7 +171,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
|
|||
LAZY_JIT_STATE.with(|lazy_jit_state| {
|
||||
let mut lazy_jit_state = lazy_jit_state.borrow_mut();
|
||||
assert!(lazy_jit_state.is_none());
|
||||
*lazy_jit_state = Some(JitState { jit_module });
|
||||
*lazy_jit_state = Some(JitState { jit_module, backend_config });
|
||||
});
|
||||
|
||||
let f: extern "C" fn(c_int, *const *const c_char) -> c_int =
|
||||
|
|
@ -205,6 +207,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
|
|||
|
||||
pub(crate) fn codegen_and_compile_fn<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
backend_config: &BackendConfig,
|
||||
cx: &mut crate::CodegenCx,
|
||||
cached_context: &mut Context,
|
||||
module: &mut dyn Module,
|
||||
|
|
@ -221,6 +224,7 @@ pub(crate) fn codegen_and_compile_fn<'tcx>(
|
|||
let cached_func = std::mem::replace(&mut cached_context.func, Function::new());
|
||||
if let Some(codegened_func) = crate::base::codegen_fn(
|
||||
tcx,
|
||||
&backend_config,
|
||||
cx,
|
||||
&mut TypeDebugContext::default(),
|
||||
cached_func,
|
||||
|
|
@ -282,7 +286,14 @@ fn jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) ->
|
|||
false,
|
||||
Symbol::intern("dummy_cgu_name"),
|
||||
);
|
||||
codegen_and_compile_fn(tcx, &mut cx, &mut Context::new(), jit_module, instance);
|
||||
codegen_and_compile_fn(
|
||||
tcx,
|
||||
&lazy_jit_state.backend_config,
|
||||
&mut cx,
|
||||
&mut Context::new(),
|
||||
jit_module,
|
||||
instance,
|
||||
);
|
||||
|
||||
assert!(cx.global_asm.is_empty());
|
||||
jit_module.finalize_definitions();
|
||||
|
|
|
|||
|
|
@ -278,7 +278,8 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Arc<dyn TargetIs
|
|||
|
||||
let mut flags_builder = settings::builder();
|
||||
flags_builder.enable("is_pic").unwrap();
|
||||
let enable_verifier = if backend_config.enable_verifier { "true" } else { "false" };
|
||||
let enable_verifier =
|
||||
if sess.verify_llvm_ir() || backend_config.enable_verifier { "true" } else { "false" };
|
||||
flags_builder.set("enable_verifier", enable_verifier).unwrap();
|
||||
flags_builder.set("regalloc_checker", enable_verifier).unwrap();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue