From 648b634e21a7d8541d84fc454700d5cb7fd7f3f4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 4 Jun 2020 19:57:12 +0200 Subject: [PATCH] Rustup to rustc 1.45.0-nightly (56daaf669 2020-06-03) --- build_sysroot/Cargo.lock | 4 ++-- example/mini_core.rs | 2 +- example/mini_core_hello_world.rs | 4 ++-- example/mod_bench.rs | 6 ++---- rust-toolchain | 2 +- src/base.rs | 7 ++++++- src/constant.rs | 31 +++++++++++++++++++------------ src/debuginfo/line_info.rs | 2 +- src/debuginfo/mod.rs | 9 +-------- 9 files changed, 35 insertions(+), 32 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 1fee499763f..d7c331de734 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -67,9 +67,9 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.28" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439a6fab343b1dab347823537734a5cd4ae6ae2000b465ab886f64cdb723bd14" +checksum = "7bc4ac2c824d2bfc612cba57708198547e9a26943af0632aff033e0693074d5c" dependencies = [ "rustc-std-workspace-core", ] diff --git a/example/mini_core.rs b/example/mini_core.rs index 8042ca89789..2732c6902b1 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -401,7 +401,7 @@ pub trait FnMut: FnOnce { #[lang = "panic"] #[track_caller] -pub fn panic(msg: &str) -> ! { +pub fn panic(_msg: &str) -> ! { unsafe { libc::puts("Panicking\n\0" as *const str as *const u8); intrinsics::abort(); diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 93eda4be31a..82014f594d2 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -414,10 +414,10 @@ pub enum E2 { fn check_niche_behavior () { if let E1::V2 { .. } = (E1::V1 { f: true }) { - unsafe { intrinsics::abort(); } + intrinsics::abort(); } if let E2::V1 { .. } = E2::V3:: { - unsafe { intrinsics::abort(); } + intrinsics::abort(); } } diff --git a/example/mod_bench.rs b/example/mod_bench.rs index 2e2b0052dee..95bcad2cd17 100644 --- a/example/mod_bench.rs +++ b/example/mod_bench.rs @@ -6,9 +6,7 @@ extern {} #[panic_handler] fn panic_handler(_: &core::panic::PanicInfo) -> ! { - unsafe { - core::intrinsics::abort(); - } + core::intrinsics::abort(); } #[lang="eh_personality"] @@ -32,6 +30,6 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize { #[inline(never)] fn black_box(i: u32) { if i != 1 { - unsafe { core::intrinsics::abort(); } + core::intrinsics::abort(); } } diff --git a/rust-toolchain b/rust-toolchain index 923f005a830..039471e8c72 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-05-25 +nightly-2020-06-04 diff --git a/src/base.rs b/src/base.rs index 16b320930d9..f6ffc372ab5 100644 --- a/src/base.rs +++ b/src/base.rs @@ -309,6 +309,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { operands, options: _, destination, + line_spans: _, } => { match template { &[] => { @@ -396,6 +397,10 @@ fn trans_stmt<'tcx>( let place = trans_place(fx, *place); place.write_place_ref(fx, lval); } + Rvalue::ThreadLocalRef(def_id) => { + let val = crate::constant::codegen_tls_ref(fx, *def_id, lval.layout()); + lval.write_cvalue(fx, val); + } Rvalue::BinaryOp(bin_op, lhs, rhs) => { let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); @@ -708,7 +713,7 @@ pub(crate) fn trans_place<'tcx>( let mut cplace = fx.get_local_place(place.local); for elem in place.projection { - match *elem { + match elem { PlaceElem::Deref => { cplace = cplace.place_deref(fx); } diff --git a/src/constant.rs b/src/constant.rs index efc7d824084..84981c72fc0 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -8,7 +8,7 @@ use rustc_middle::ty::{Const, ConstKind}; use rustc_target::abi::Align; use rustc_data_structures::fx::FxHashSet; -use cranelift_codegen::ir::GlobalValue; +use cranelift_codegen::ir::GlobalValueData; use cranelift_module::*; use crate::prelude::*; @@ -38,6 +38,20 @@ pub(crate) fn codegen_static(constants_cx: &mut ConstantCx, def_id: DefId) { constants_cx.todo.push(TodoItem::Static(def_id)); } +pub(crate) fn codegen_tls_ref<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + def_id: DefId, + layout: TyAndLayout<'tcx>, +) -> CValue<'tcx> { + let linkage = crate::linkage::get_static_ref_linkage(fx.tcx, def_id); + let data_id = data_id_for_static(fx.tcx, fx.module, def_id, linkage); + let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + #[cfg(debug_assertions)] + fx.add_comment(local_data_id, format!("tls {:?}", def_id)); + let tls_ptr = fx.bcx.ins().tls_value(fx.pointer_type, local_data_id); + CValue::by_val(tls_ptr, layout) +} + fn codegen_static_ref<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, def_id: DefId, @@ -48,7 +62,10 @@ fn codegen_static_ref<'tcx>( let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); - cplace_for_dataid(fx, layout, local_data_id) + let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); + assert!(!layout.is_unsized(), "unsized statics aren't supported"); + assert!(matches!(fx.bcx.func.global_values[local_data_id], GlobalValueData::Symbol { tls: false, ..}), "tls static referenced without Rvalue::ThreadLocalRef"); + CPlace::for_ptr(crate::pointer::Pointer::new(global_ptr), layout) } pub(crate) fn trans_constant<'tcx>( @@ -245,16 +262,6 @@ fn data_id_for_static( data_id } -fn cplace_for_dataid<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - layout: TyAndLayout<'tcx>, - local_data_id: GlobalValue, -) -> CPlace<'tcx> { - let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); - assert!(!layout.is_unsized(), "unsized statics aren't supported"); - CPlace::for_ptr(crate::pointer::Pointer::new(global_ptr), layout) -} - fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mut ConstantCx) { while let Some(todo_item) = cx.todo.pop() { let (data_id, alloc) = match todo_item { diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 83e462c8193..31431404cc3 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -59,7 +59,7 @@ fn line_program_add_file( ) -> FileId { match &file.name { FileName::Real(path) => { - let (dir_path, file_name) = split_path_dir_and_file(path); + let (dir_path, file_name) = split_path_dir_and_file(path.stable_name()); let dir_name = osstr_as_utf8_bytes(dir_path.as_os_str()); let file_name = osstr_as_utf8_bytes(file_name); diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 2a360dd00c2..d13067bb3ff 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -4,8 +4,6 @@ mod unwind; use crate::prelude::*; -use rustc_span::FileName; - use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc}; use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::ValueLocRange; @@ -66,12 +64,7 @@ impl<'tcx> DebugContext<'tcx> { let (name, file_info) = match tcx.sess.local_crate_source_file.clone() { Some(path) => { let name = path.to_string_lossy().into_owned(); - let info = tcx.sess - .source_map() - .get_source_file(&FileName::Real(path)) - .map(|f| f.src_hash) - .and_then(line_info::make_file_info); - (name, info) + (name, None) }, None => (tcx.crate_name(LOCAL_CRATE).to_string(), None), };