Only call build_value_labels_ranges when necessary
This commit is contained in:
parent
d4187e6aae
commit
3086e44733
31
src/base.rs
31
src/base.rs
@ -73,7 +73,14 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>(
|
||||
let local_map = fx.local_map;
|
||||
let cold_blocks = fx.cold_blocks;
|
||||
|
||||
crate::pretty_clif::write_clif_file(cx.tcx, "unopt", instance, &context.func, &clif_comments, None);
|
||||
crate::pretty_clif::write_clif_file(
|
||||
cx.tcx,
|
||||
"unopt",
|
||||
None,
|
||||
instance,
|
||||
&context,
|
||||
&clif_comments,
|
||||
);
|
||||
|
||||
// Verify function
|
||||
verify_func(tcx, &clif_comments, &context.func);
|
||||
@ -101,20 +108,14 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>(
|
||||
);
|
||||
|
||||
// Write optimized function to file for debugging
|
||||
{
|
||||
let value_ranges = context
|
||||
.build_value_labels_ranges(cx.module.isa())
|
||||
.expect("value location ranges");
|
||||
|
||||
crate::pretty_clif::write_clif_file(
|
||||
cx.tcx,
|
||||
"opt",
|
||||
instance,
|
||||
&context.func,
|
||||
&clif_comments,
|
||||
Some(&value_ranges),
|
||||
);
|
||||
}
|
||||
crate::pretty_clif::write_clif_file(
|
||||
cx.tcx,
|
||||
"opt",
|
||||
Some(cx.module.isa()),
|
||||
instance,
|
||||
&context,
|
||||
&clif_comments,
|
||||
);
|
||||
|
||||
// Define debuginfo for function
|
||||
let isa = cx.module.isa();
|
||||
|
@ -18,6 +18,6 @@ pub(crate) fn optimize_function<'tcx>(
|
||||
return; // FIXME classify optimizations over opt levels
|
||||
}
|
||||
self::stack2reg::optimize_function(ctx, clif_comments);
|
||||
crate::pretty_clif::write_clif_file(tcx, "stack2reg", instance, &ctx.func, &*clif_comments, None);
|
||||
crate::pretty_clif::write_clif_file(tcx, "stack2reg", None, instance, &ctx, &*clif_comments);
|
||||
crate::base::verify_func(tcx, &*clif_comments, &ctx.func);
|
||||
}
|
||||
|
@ -203,16 +203,22 @@ impl<B: Backend + 'static> FunctionCx<'_, '_, B> {
|
||||
pub(crate) fn write_clif_file<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
postfix: &str,
|
||||
isa: Option<&dyn cranelift_codegen::isa::TargetIsa>,
|
||||
instance: Instance<'tcx>,
|
||||
func: &cranelift_codegen::ir::Function,
|
||||
context: &cranelift_codegen::Context,
|
||||
mut clif_comments: &CommentWriter,
|
||||
value_ranges: Option<&cranelift_codegen::ValueLabelsRanges>,
|
||||
) {
|
||||
use std::io::Write;
|
||||
|
||||
if !cfg!(debug_assertions) && !tcx.sess.opts.output_types.contains_key(&OutputType::LlvmAssembly) {
|
||||
return;
|
||||
}
|
||||
|
||||
use std::io::Write;
|
||||
let value_ranges = isa.map(|isa| {
|
||||
context
|
||||
.build_value_labels_ranges(isa)
|
||||
.expect("value location ranges")
|
||||
});
|
||||
|
||||
let symbol_name = tcx.symbol_name(instance).name.as_str();
|
||||
let clif_file_name = format!(
|
||||
@ -227,12 +233,12 @@ pub(crate) fn write_clif_file<'tcx>(
|
||||
cranelift_codegen::write::decorate_function(
|
||||
&mut clif_comments,
|
||||
&mut clif,
|
||||
&func,
|
||||
&context.func,
|
||||
&DisplayFunctionAnnotations {
|
||||
isa: Some(&*crate::build_isa(
|
||||
tcx.sess, true, /* PIC doesn't matter here */
|
||||
)),
|
||||
value_ranges,
|
||||
value_ranges: value_ranges.as_ref(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user