This commit is contained in:
bjorn3 2021-12-07 17:57:58 +01:00
commit 7d34d3ad78
3 changed files with 19 additions and 9 deletions

View File

@ -42,7 +42,7 @@ fn main() {
"RUSTFLAGS", "RUSTFLAGS",
env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic", env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
); );
std::array::IntoIter::new(["rustc".to_string()]) IntoIterator::into_iter(["rustc".to_string()])
.chain(env::args().skip(2)) .chain(env::args().skip(2))
.chain([ .chain([
"--".to_string(), "--".to_string(),
@ -56,7 +56,7 @@ fn main() {
"RUSTFLAGS", "RUSTFLAGS",
env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic", env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
); );
std::array::IntoIter::new(["rustc".to_string()]) IntoIterator::into_iter(["rustc".to_string()])
.chain(env::args().skip(2)) .chain(env::args().skip(2))
.chain([ .chain([
"--".to_string(), "--".to_string(),

View File

@ -71,7 +71,7 @@ fn apply_arg_attrs_to_abi_param(mut param: AbiParam, arg_attrs: ArgAttributes) -
.prefix .prefix
.iter() .iter()
.flatten() .flatten()
.map(|&kind| reg_to_abi_param(Reg { kind, size: cast.prefix_chunk_size })) .map(|&reg| reg_to_abi_param(reg))
.chain((0..rest_count).map(|_| reg_to_abi_param(cast.rest.unit))) .chain((0..rest_count).map(|_| reg_to_abi_param(cast.rest.unit)))
.collect::<SmallVec<_>>(); .collect::<SmallVec<_>>();

View File

@ -1,6 +1,7 @@
//! Codegen of a single function //! Codegen of a single function
use cranelift_codegen::binemit::{NullStackMapSink, NullTrapSink}; use cranelift_codegen::binemit::{NullStackMapSink, NullTrapSink};
use rustc_ast::InlineAsmOptions;
use rustc_index::vec::IndexVec; use rustc_index::vec::IndexVec;
use rustc_middle::ty::adjustment::PointerCast; use rustc_middle::ty::adjustment::PointerCast;
use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::layout::FnAbiOf;
@ -236,7 +237,8 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
fx.add_comment(inst, terminator_head); fx.add_comment(inst, terminator_head);
} }
fx.set_debug_loc(bb_data.terminator().source_info); let source_info = bb_data.terminator().source_info;
fx.set_debug_loc(source_info);
match &bb_data.terminator().kind { match &bb_data.terminator().kind {
TerminatorKind::Goto { target } => { TerminatorKind::Goto { target } => {
@ -292,19 +294,19 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
let len = codegen_operand(fx, len).load_scalar(fx); let len = codegen_operand(fx, len).load_scalar(fx);
let index = codegen_operand(fx, index).load_scalar(fx); let index = codegen_operand(fx, index).load_scalar(fx);
let location = fx let location = fx
.get_caller_location(bb_data.terminator().source_info.span) .get_caller_location(source_info.span)
.load_scalar(fx); .load_scalar(fx);
codegen_panic_inner( codegen_panic_inner(
fx, fx,
rustc_hir::LangItem::PanicBoundsCheck, rustc_hir::LangItem::PanicBoundsCheck,
&[index, len, location], &[index, len, location],
bb_data.terminator().source_info.span, source_info.span,
); );
} }
_ => { _ => {
let msg_str = msg.description(); let msg_str = msg.description();
codegen_panic(fx, msg_str, bb_data.terminator().source_info.span); codegen_panic(fx, msg_str, source_info.span);
} }
} }
} }
@ -375,10 +377,18 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
options, options,
destination, destination,
line_spans: _, line_spans: _,
cleanup: _,
} => { } => {
if options.contains(InlineAsmOptions::MAY_UNWIND) {
fx.tcx.sess.span_fatal(
source_info.span,
"cranelift doesn't support unwinding from inline assembly.",
);
}
crate::inline_asm::codegen_inline_asm( crate::inline_asm::codegen_inline_asm(
fx, fx,
bb_data.terminator().source_info.span, source_info.span,
template, template,
operands, operands,
*options, *options,
@ -412,7 +422,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
} }
TerminatorKind::Drop { place, target, unwind: _ } => { TerminatorKind::Drop { place, target, unwind: _ } => {
let drop_place = codegen_place(fx, *place); let drop_place = codegen_place(fx, *place);
crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place); crate::abi::codegen_drop(fx, source_info.span, drop_place);
let target_block = fx.get_block(*target); let target_block = fx.get_block(*target);
fx.bcx.ins().jump(target_block, &[]); fx.bcx.ins().jump(target_block, &[]);