Merge commit '370c397ec9
' into sync_cg_clif-2022-03-20
This commit is contained in:
commit
ef4ce72919
32 changed files with 462 additions and 515 deletions
|
@ -4,6 +4,7 @@ use rustc_ast::InlineAsmOptions;
|
|||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::layout::FnAbiOf;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
|
||||
use indexmap::IndexSet;
|
||||
|
||||
|
@ -25,7 +26,10 @@ pub(crate) fn codegen_fn<'tcx>(
|
|||
let mir = tcx.instance_mir(instance.def);
|
||||
let _mir_guard = crate::PrintOnPanic(|| {
|
||||
let mut buf = Vec::new();
|
||||
rustc_middle::mir::write_mir_pretty(tcx, Some(instance.def_id()), &mut buf).unwrap();
|
||||
with_no_trimmed_paths!({
|
||||
rustc_middle::mir::pretty::write_mir_fn(tcx, mir, &mut |_, _| Ok(()), &mut buf)
|
||||
.unwrap();
|
||||
});
|
||||
String::from_utf8_lossy(&buf).into_owned()
|
||||
});
|
||||
|
||||
|
@ -90,7 +94,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
|||
} else if arg_uninhabited {
|
||||
fx.bcx.append_block_params_for_function_params(fx.block_map[START_BLOCK]);
|
||||
fx.bcx.switch_to_block(fx.block_map[START_BLOCK]);
|
||||
crate::trap::trap_unreachable(&mut fx, "function has uninhabited argument");
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
} else {
|
||||
tcx.sess.time("codegen clif ir", || {
|
||||
tcx.sess
|
||||
|
@ -258,7 +262,9 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
|
|||
|
||||
if fx.clif_comments.enabled() {
|
||||
let mut terminator_head = "\n".to_string();
|
||||
bb_data.terminator().kind.fmt_head(&mut terminator_head).unwrap();
|
||||
with_no_trimmed_paths!({
|
||||
bb_data.terminator().kind.fmt_head(&mut terminator_head).unwrap();
|
||||
});
|
||||
let inst = fx.bcx.func.layout.last_inst(block).unwrap();
|
||||
fx.add_comment(inst, terminator_head);
|
||||
}
|
||||
|
@ -303,7 +309,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
|
|||
|
||||
let target = fx.get_block(*target);
|
||||
let failure = fx.bcx.create_block();
|
||||
// FIXME Mark failure block as cold once Cranelift supports it
|
||||
fx.bcx.set_cold_block(failure);
|
||||
|
||||
if *expected {
|
||||
fx.bcx.ins().brz(cond, failure, &[]);
|
||||
|
@ -424,18 +430,16 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
|
|||
fx.bcx.ins().jump(destination_block, &[]);
|
||||
}
|
||||
None => {
|
||||
crate::trap::trap_unreachable(
|
||||
fx,
|
||||
"[corruption] Returned from noreturn inline asm",
|
||||
);
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
}
|
||||
}
|
||||
TerminatorKind::Resume | TerminatorKind::Abort => {
|
||||
trap_unreachable(fx, "[corruption] Unwinding bb reached.");
|
||||
// FIXME implement unwinding
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
TerminatorKind::Unreachable => {
|
||||
trap_unreachable(fx, "[corruption] Hit unreachable code.");
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
TerminatorKind::Yield { .. }
|
||||
| TerminatorKind::FalseEdge { .. }
|
||||
|
@ -813,7 +817,14 @@ pub(crate) fn codegen_place<'tcx>(
|
|||
for elem in place.projection {
|
||||
match elem {
|
||||
PlaceElem::Deref => {
|
||||
cplace = cplace.place_deref(fx);
|
||||
if cplace.layout().ty.is_box() {
|
||||
cplace = cplace
|
||||
.place_field(fx, Field::new(0)) // Box<T> -> Unique<T>
|
||||
.place_field(fx, Field::new(0)) // Unique<T> -> *const T
|
||||
.place_deref(fx);
|
||||
} else {
|
||||
cplace = cplace.place_deref(fx);
|
||||
}
|
||||
}
|
||||
PlaceElem::Field(field, _ty) => {
|
||||
cplace = cplace.place_field(fx, field);
|
||||
|
@ -918,5 +929,5 @@ pub(crate) fn codegen_panic_inner<'tcx>(
|
|||
args,
|
||||
);
|
||||
|
||||
crate::trap::trap_unreachable(fx, "panic lang item returned");
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue