Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6dd0246

Browse files
committed
Dump clif with --emit llvm-ir in release mode
Currently it's not possible to dump llvm-ir in release build. With this patch we allow it with `--emit llvm-ir`. In debug build we dump clif always as before. Fixes rust-lang#1020
1 parent 1c76bdc commit 6dd0246

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/base.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
7777
let local_map = fx.local_map;
7878
let cold_blocks = fx.cold_blocks;
7979

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

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

108107
// Write optimized function to file for debugging
109-
#[cfg(debug_assertions)]
110108
{
111109
let value_ranges = context
112110
.build_value_labels_ranges(cx.module.isa())

src/optimize/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub(crate) fn optimize_function<'tcx>(
1818
return; // FIXME classify optimizations over opt levels
1919
}
2020
self::stack2reg::optimize_function(ctx, clif_comments);
21-
#[cfg(debug_assertions)]
2221
crate::pretty_clif::write_clif_file(tcx, "stack2reg", instance, &ctx.func, &*clif_comments, None);
2322
crate::base::verify_func(tcx, &*clif_comments, &ctx.func);
2423
}

src/pretty_clif.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use cranelift_codegen::{
66
write::{FuncWriter, PlainWriter},
77
};
88

9+
use rustc_session::config::OutputType;
10+
911
use crate::prelude::*;
1012

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

201-
#[cfg(debug_assertions)]
202203
pub(crate) fn write_clif_file<'tcx>(
203204
tcx: TyCtxt<'tcx>,
204205
postfix: &str,
@@ -207,6 +208,10 @@ pub(crate) fn write_clif_file<'tcx>(
207208
mut clif_comments: &CommentWriter,
208209
value_ranges: Option<&cranelift_codegen::ValueLabelsRanges>,
209210
) {
211+
if !(cfg!(debug_assertions) || tcx.sess.opts.output_types.contains_key(&OutputType::LlvmAssembly)) {
212+
return;
213+
}
214+
210215
use std::io::Write;
211216

212217
let symbol_name = tcx.symbol_name(instance).name.as_str();

0 commit comments

Comments
 (0)