Reduce verbosity of output
This commit is contained in:
parent
a3760040b2
commit
ca59e4405e
5 changed files with 29 additions and 9 deletions
3
build.sh
3
build.sh
|
@ -23,6 +23,8 @@ extract_data() {
|
|||
RUSTC="rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=target/out --out-dir target/out"
|
||||
|
||||
rm -r target/out
|
||||
mkdir -p target/out/mir
|
||||
mkdir -p target/out/clif
|
||||
|
||||
SHOULD_CODEGEN=1 $RUSTC examples/mini_core.rs --crate-name mini_core --crate-type lib &&
|
||||
extract_data libmini_core.rlib mini_core.o &&
|
||||
|
@ -39,4 +41,3 @@ gcc target/out/mini_core.o target/out/mini_core_hello_world.o -o target/out/mini
|
|||
|
||||
$RUSTC target/libcore/src/libcore/lib.rs --color=always --crate-type lib -Cincremental=target/incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000)
|
||||
cat target/libcore/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len"
|
||||
|
||||
|
|
|
@ -242,7 +242,6 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(
|
|||
start_ebb: Ebb,
|
||||
) {
|
||||
let ssa_analyzed = crate::analyze::analyze(fx);
|
||||
fx.tcx.sess.warn(&format!("ssa {:?}", ssa_analyzed));
|
||||
|
||||
match fx.self_sig().abi {
|
||||
Abi::Rust | Abi::RustCall => {}
|
||||
|
@ -301,6 +300,9 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(
|
|||
|
||||
fx.bcx.switch_to_block(start_ebb);
|
||||
|
||||
fx.top_nop = Some(fx.bcx.ins().nop());
|
||||
fx.add_global_comment(format!("ssa {:?}", ssa_analyzed));
|
||||
|
||||
match output_pass_mode {
|
||||
PassMode::NoPass => {
|
||||
let null = fx.bcx.ins().iconst(types::I64, 0);
|
||||
|
|
24
src/base.rs
24
src/base.rs
|
@ -1,5 +1,14 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
struct PrintOnPanic(String);
|
||||
impl Drop for PrintOnPanic {
|
||||
fn drop(&mut self) {
|
||||
if ::std::thread::panicking() {
|
||||
println!("{}", self.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, mono_item: MonoItem<'tcx>) {
|
||||
let tcx = cx.tcx;
|
||||
let context = &mut cx.context;
|
||||
|
@ -12,11 +21,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, mono_item: Mo
|
|||
} => {
|
||||
let mut mir = ::std::io::Cursor::new(Vec::new());
|
||||
::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap();
|
||||
tcx.sess.warn(&format!(
|
||||
"{:?}:\n\n{}",
|
||||
inst,
|
||||
String::from_utf8_lossy(&mir.into_inner())
|
||||
));
|
||||
let mir_file_name = "target/out/mir/".to_string() + &format!("{:?}", def_id).replace('/', "@");
|
||||
::std::fs::write(mir_file_name, mir.into_inner()).unwrap();
|
||||
let _print_guard = PrintOnPanic(format!("{:?}", inst));
|
||||
|
||||
let res = each_module!(cx, |(ccx, m)| trans_fn(tcx, *m, ccx, context, inst));
|
||||
if let Some(func_id) = res.jit {
|
||||
|
@ -84,6 +91,8 @@ fn trans_fn<'a, 'tcx: 'a>(
|
|||
local_map: HashMap::new(),
|
||||
comments: HashMap::new(),
|
||||
constants,
|
||||
|
||||
top_nop: None,
|
||||
};
|
||||
|
||||
// Step 6. Codegen function
|
||||
|
@ -96,7 +105,8 @@ fn trans_fn<'a, 'tcx: 'a>(
|
|||
let mut writer = crate::pretty_clif::CommentWriter(fx.comments);
|
||||
let mut cton = String::new();
|
||||
::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None).unwrap();
|
||||
tcx.sess.warn(&cton);
|
||||
let clif_file_name = "target/out/clif/".to_string() + &tcx.symbol_name(instance).as_str();
|
||||
::std::fs::write(clif_file_name, cton.as_bytes()).unwrap();
|
||||
|
||||
// Step 8. Verify function
|
||||
verify_func(tcx, writer, &func);
|
||||
|
@ -235,7 +245,7 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
|||
cur_ebb: Ebb,
|
||||
stmt: &Statement<'tcx>,
|
||||
) {
|
||||
fx.tcx.sess.warn(&format!("stmt {:?}", stmt));
|
||||
let _print_guard = PrintOnPanic(format!("stmt {:?}", stmt));
|
||||
|
||||
let inst = fx.bcx.func.layout.last_inst(cur_ebb).unwrap();
|
||||
fx.add_comment(inst, format!("{:?}", stmt));
|
||||
|
|
|
@ -361,6 +361,9 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend + 'a> {
|
|||
pub local_map: HashMap<Local, CPlace<'tcx>>,
|
||||
pub comments: HashMap<Inst, String>,
|
||||
pub constants: &'a mut crate::constant::ConstantCx,
|
||||
|
||||
/// add_global_comment inserts a comment here
|
||||
pub top_nop: Option<Inst>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> {
|
||||
|
|
|
@ -35,6 +35,10 @@ impl FuncWriter for CommentWriter {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> {
|
||||
pub fn add_global_comment<'s, S: Into<Cow<'s, str>>>(&mut self, comment: S) {
|
||||
self.add_comment(self.top_nop.expect("fx.top_nop not yet set"), comment)
|
||||
}
|
||||
|
||||
pub fn add_comment<'s, S: Into<Cow<'s, str>>>(&mut self, inst: Inst, comment: S) {
|
||||
use std::collections::hash_map::Entry;
|
||||
match self.comments.entry(inst) {
|
||||
|
|
Loading…
Reference in a new issue