Skip to content

Commit

Permalink
Merge pull request #1022 from osa1/clif_dump_in_release_mode
Browse files Browse the repository at this point in the history
Dump clif with --emit llvm-ir in release mode
  • Loading branch information
bjorn3 committed May 29, 2020
2 parents acbfa06 + c0ad988 commit 1e70c51
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/base.rs
Expand Up @@ -77,7 +77,6 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
let local_map = fx.local_map;
let cold_blocks = fx.cold_blocks;

#[cfg(debug_assertions)]
crate::pretty_clif::write_clif_file(cx.tcx, "unopt", instance, &context.func, &clif_comments, None);

// Verify function
Expand Down Expand Up @@ -106,7 +105,6 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
);

// Write optimized function to file for debugging
#[cfg(debug_assertions)]
{
let value_ranges = context
.build_value_labels_ranges(cx.module.isa())
Expand Down
1 change: 0 additions & 1 deletion src/optimize/mod.rs
Expand Up @@ -18,7 +18,6 @@ pub(crate) fn optimize_function<'tcx>(
return; // FIXME classify optimizations over opt levels
}
self::stack2reg::optimize_function(ctx, clif_comments);
#[cfg(debug_assertions)]
crate::pretty_clif::write_clif_file(tcx, "stack2reg", instance, &ctx.func, &*clif_comments, None);
crate::base::verify_func(tcx, &*clif_comments, &ctx.func);
}
7 changes: 6 additions & 1 deletion src/pretty_clif.rs
Expand Up @@ -6,6 +6,8 @@ use cranelift_codegen::{
write::{FuncWriter, PlainWriter},
};

use rustc_session::config::OutputType;

use crate::prelude::*;

/// This module provides the [CommentWriter] which makes it possible
Expand Down Expand Up @@ -198,7 +200,6 @@ impl<B: Backend + 'static> FunctionCx<'_, '_, B> {
}
}

#[cfg(debug_assertions)]
pub(crate) fn write_clif_file<'tcx>(
tcx: TyCtxt<'tcx>,
postfix: &str,
Expand All @@ -207,6 +208,10 @@ pub(crate) fn write_clif_file<'tcx>(
mut clif_comments: &CommentWriter,
value_ranges: Option<&cranelift_codegen::ValueLabelsRanges>,
) {
if !cfg!(debug_assertions) && !tcx.sess.opts.output_types.contains_key(&OutputType::LlvmAssembly) {
return;
}

use std::io::Write;

let symbol_name = tcx.symbol_name(instance).name.as_str();
Expand Down

0 comments on commit 1e70c51

Please sign in to comment.