More debugging output
This commit is contained in:
parent
0c592a6bb1
commit
25fef30186
3 changed files with 28 additions and 7 deletions
|
|
@ -29,15 +29,15 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend
|
|||
|
||||
let comments = ::base::trans_fn(cx, &mut f, inst);
|
||||
|
||||
let mut writer = ::pretty_clif::CommentWriter(comments);
|
||||
let mut cton = String::new();
|
||||
::cranelift::codegen::write_function(&mut cton, &f, None).unwrap();
|
||||
::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &f, None).unwrap();
|
||||
tcx.sess.warn(&cton);
|
||||
|
||||
let flags = settings::Flags::new(settings::builder());
|
||||
match ::cranelift::codegen::verify_function(&f, &flags) {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
let writer = ::pretty_clif::CommentWriter(comments);
|
||||
let pretty_error = ::cranelift::codegen::print_errors::pretty_verifier_error(&f, None, Some(Box::new(writer)), &err);
|
||||
tcx.sess.fatal(&format!("cretonne verify error:\n{}", pretty_error));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
extern crate rustc_target;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
|
||||
use syntax::ast::{IntTy, UintTy};
|
||||
use self::rustc_target::spec::{HasTargetSpec, Target};
|
||||
|
|
@ -187,8 +188,9 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> {
|
|||
pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>, from: CValue<'tcx>) {
|
||||
assert_eq!(
|
||||
self.layout().ty, from.layout().ty,
|
||||
"Can't write value of incompatible type to place {:?} {:?}",
|
||||
self.layout().ty.sty, from.layout().ty.sty
|
||||
"Can't write value of incompatible type to place {:?} {:?}\n\n{:#?}",
|
||||
self.layout().ty.sty, from.layout().ty.sty,
|
||||
fx,
|
||||
);
|
||||
|
||||
match self {
|
||||
|
|
@ -298,6 +300,24 @@ pub struct FunctionCx<'a, 'tcx: 'a> {
|
|||
pub comments: HashMap<Inst, String>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx: 'a> fmt::Debug for FunctionCx<'a, 'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
writeln!(f, "{:?}", self.def_id_fn_id_map)?;
|
||||
writeln!(f, "{:?}", self.param_substs)?;
|
||||
writeln!(f, "{:?}", self.local_map)?;
|
||||
|
||||
let mut clif = String::new();
|
||||
let mut writer = ::pretty_clif::CommentWriter(self.comments.clone());
|
||||
::cranelift::codegen::write::decorate_function(
|
||||
&mut writer,
|
||||
&mut clif,
|
||||
&self.bcx.func,
|
||||
None,
|
||||
).unwrap();
|
||||
writeln!(f, "\n{}", clif)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx: 'a> LayoutOf for &'a FunctionCx<'a, 'tcx> {
|
||||
type Ty = Ty<'tcx>;
|
||||
type TyLayout = TyLayout<'tcx>;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ use std::fmt;
|
|||
|
||||
use cranelift::codegen::{
|
||||
ir::{Function, Inst},
|
||||
FuncWriter,
|
||||
PlainWriter,
|
||||
write::{FuncWriter, PlainWriter},
|
||||
};
|
||||
use cranelift::prelude::*;
|
||||
|
||||
|
|
@ -19,7 +18,9 @@ impl FuncWriter for CommentWriter {
|
|||
inst: Inst,
|
||||
indent: usize,
|
||||
) -> fmt::Result {
|
||||
|
||||
if let Some(comment) = self.0.get(&inst) {
|
||||
writeln!(w, "; {}", comment.replace('\n', "\n; "))?;
|
||||
}
|
||||
PlainWriter.write_instruction(w, func, isa, inst, indent)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue