Sync from rust 8521a8c92d
This commit is contained in:
commit
b80970f27f
@ -342,7 +342,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
||||
|
||||
let ret_place = codegen_place(fx, destination);
|
||||
|
||||
// Handle special calls like instrinsics and empty drop glue.
|
||||
// Handle special calls like intrinsics and empty drop glue.
|
||||
let instance = if let ty::FnDef(def_id, substs) = *fn_ty.kind() {
|
||||
let instance = ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs)
|
||||
.unwrap()
|
||||
|
@ -925,8 +925,11 @@ pub(crate) fn codegen_panic_inner<'tcx>(
|
||||
args: &[Value],
|
||||
span: Span,
|
||||
) {
|
||||
let def_id =
|
||||
fx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| fx.tcx.sess.span_fatal(span, &s));
|
||||
let def_id = fx
|
||||
.tcx
|
||||
.lang_items()
|
||||
.require(lang_item)
|
||||
.unwrap_or_else(|e| fx.tcx.sess.span_fatal(span, e.to_string()));
|
||||
|
||||
let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx);
|
||||
let symbol_name = fx.tcx.symbol_name(instance).name;
|
||||
|
@ -59,7 +59,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
|
||||
ErrorHandled::TooGeneric => {
|
||||
span_bug!(
|
||||
constant.span,
|
||||
"codgen encountered polymorphic constant: {:?}",
|
||||
"codegen encountered polymorphic constant: {:?}",
|
||||
err
|
||||
);
|
||||
}
|
||||
@ -430,7 +430,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
|
||||
let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()).to_vec();
|
||||
data_ctx.define(bytes.into_boxed_slice());
|
||||
|
||||
for &(offset, alloc_id) in alloc.relocations().iter() {
|
||||
for &(offset, alloc_id) in alloc.provenance().iter() {
|
||||
let addend = {
|
||||
let endianness = tcx.data_layout.endian;
|
||||
let offset = offset.bytes() as usize;
|
||||
|
@ -203,7 +203,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
|
||||
sym::transmute => {
|
||||
crate::base::codegen_panic(fx, "Transmuting to uninhabited type.", source_info);
|
||||
}
|
||||
_ => unimplemented!("unsupported instrinsic {}", intrinsic),
|
||||
_ => unimplemented!("unsupported intrinsic {}", intrinsic),
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
@ -186,7 +186,10 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
let size = Size::from_bytes(
|
||||
4 * ret_lane_count, /* size_of([u32; ret_lane_count]) */
|
||||
);
|
||||
alloc.inner().get_bytes(fx, alloc_range(offset, size)).unwrap()
|
||||
alloc
|
||||
.inner()
|
||||
.get_bytes_strip_provenance(fx, alloc_range(offset, size))
|
||||
.unwrap()
|
||||
}
|
||||
_ => unreachable!("{:?}", idx_const),
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_middle::ty::subst::GenericArg;
|
||||
use rustc_middle::ty::AssocKind;
|
||||
use rustc_session::config::EntryFnType;
|
||||
use rustc_session::config::{sigpipe, EntryFnType};
|
||||
use rustc_span::symbol::Ident;
|
||||
|
||||
use crate::prelude::*;
|
||||
@ -15,12 +15,12 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
is_jit: bool,
|
||||
is_primary_cgu: bool,
|
||||
) {
|
||||
let (main_def_id, is_main_fn) = match tcx.entry_fn(()) {
|
||||
let (main_def_id, (is_main_fn, sigpipe)) = match tcx.entry_fn(()) {
|
||||
Some((def_id, entry_ty)) => (
|
||||
def_id,
|
||||
match entry_ty {
|
||||
EntryFnType::Main => true,
|
||||
EntryFnType::Start => false,
|
||||
EntryFnType::Main { sigpipe } => (true, sigpipe),
|
||||
EntryFnType::Start => (false, sigpipe::DEFAULT),
|
||||
},
|
||||
),
|
||||
None => return,
|
||||
@ -35,7 +35,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
return;
|
||||
}
|
||||
|
||||
create_entry_fn(tcx, module, unwind_context, main_def_id, is_jit, is_main_fn);
|
||||
create_entry_fn(tcx, module, unwind_context, main_def_id, is_jit, is_main_fn, sigpipe);
|
||||
|
||||
fn create_entry_fn(
|
||||
tcx: TyCtxt<'_>,
|
||||
@ -44,6 +44,7 @@ fn create_entry_fn(
|
||||
rust_main_def_id: DefId,
|
||||
ignore_lang_start_wrapper: bool,
|
||||
is_main_fn: bool,
|
||||
sigpipe: u8,
|
||||
) {
|
||||
let main_ret_ty = tcx.fn_sig(rust_main_def_id).output();
|
||||
// Given that `main()` has no arguments,
|
||||
@ -83,6 +84,7 @@ fn create_entry_fn(
|
||||
bcx.switch_to_block(block);
|
||||
let arg_argc = bcx.append_block_param(block, m.target_config().pointer_type());
|
||||
let arg_argv = bcx.append_block_param(block, m.target_config().pointer_type());
|
||||
let arg_sigpipe = bcx.ins().iconst(types::I8, sigpipe as i64);
|
||||
|
||||
let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func);
|
||||
|
||||
@ -143,7 +145,8 @@ fn create_entry_fn(
|
||||
let main_val = bcx.ins().func_addr(m.target_config().pointer_type(), main_func_ref);
|
||||
|
||||
let func_ref = m.declare_func_in_func(start_func_id, &mut bcx.func);
|
||||
let call_inst = bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv]);
|
||||
let call_inst =
|
||||
bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv, arg_sigpipe]);
|
||||
bcx.inst_results(call_inst)[0]
|
||||
} else {
|
||||
// using user-defined start fn
|
||||
|
Loading…
Reference in New Issue
Block a user